|
| 1 | +# Primer CSS / Subhead |
| 2 | + |
| 3 | +[](https://www.npmjs.org/package/primer-subhead) |
| 4 | +[](https://travis-ci.org/primer/primer-css) |
| 5 | + |
| 6 | +> The Subhead is a simple header with a bottom border. It's designed to be used on settings and configuration pages. |
| 7 | +
|
| 8 | +This repository is a module of the full [primer-css][primer-css] repository. |
| 9 | + |
| 10 | +## Install |
| 11 | + |
| 12 | +This repository is distributed with [npm]. After [installing npm][install-npm], you can install `primer-subhead` with this command. |
| 13 | + |
| 14 | +``` |
| 15 | +$ npm install --save primer-subhead |
| 16 | +``` |
| 17 | + |
| 18 | +## Usage |
| 19 | + |
| 20 | +The source files included are written in [Sass][sass] (SCSS) You can simply point your sass `include-path` at your `node_modules` directory and import it like this. |
| 21 | + |
| 22 | +```scss |
| 23 | +@import "primer-subhead/index.scss"; |
| 24 | +``` |
| 25 | + |
| 26 | +You can also import specific portions of the module by importing those partials from the `/lib/` folder. _Make sure you import any requirements along with the modules._ |
| 27 | + |
| 28 | +## Build |
| 29 | + |
| 30 | +For a compiled **CSS** version of this module, an npm script is included that will output a css version to `build/build.css` The built css file is also included in the npm package: |
| 31 | + |
| 32 | +``` |
| 33 | +$ npm run build |
| 34 | +``` |
| 35 | + |
| 36 | +## Documentation |
| 37 | + |
| 38 | +<!-- %docs |
| 39 | +title: Subhead |
| 40 | +status: New release |
| 41 | +status_issue: https://github.com/github/design-systems/issues/101 |
| 42 | +--> |
| 43 | + |
| 44 | +The basic Subhead consists of a `.Subhead` container, which has a light gray bottom border. Use `.Subhead-heading` for the heading itself. It's an `<h2>` sized heading with normal font-weight. |
| 45 | + |
| 46 | +Use a heading element whenever possible as they can be used as navigation for assistive technologies, and avoid skipping levels. |
| 47 | + |
| 48 | +```html |
| 49 | +<div class="Subhead"> |
| 50 | + <div class="Subhead-heading">Plain subhead</div> |
| 51 | +</div> |
| 52 | +``` |
| 53 | + |
| 54 | +To add a top margin to the Subhead, use `.Subhead--spacious`. This is useful for separating sections on a settings page. |
| 55 | + |
| 56 | +```html |
| 57 | +<div class="Subhead Subhead--spacious"> |
| 58 | + <div class="Subhead-heading">Spacious subhead</div> |
| 59 | +</div> |
| 60 | +``` |
| 61 | + |
| 62 | +You can add a one line description to the subhead with `.Subhead-description`. |
| 63 | + |
| 64 | +```html |
| 65 | +<div class="Subhead"> |
| 66 | + <div class="Subhead-heading">Subhead with description</div> |
| 67 | + <div class="Subhead-description">The subhead is a subdued header style with a light bottom border.</div> |
| 68 | +</div> |
| 69 | +``` |
| 70 | + |
| 71 | +For longer descriptions, it is recommended that you use a paragraph below the Subhead. |
| 72 | + |
| 73 | +```html |
| 74 | +<div class="Subhead"> |
| 75 | + <div class="Subhead-heading">Plain subhead</div> |
| 76 | +</div> |
| 77 | +<p> |
| 78 | + This is a longer description that is sitting below the Subheader. It's much longer than a description that could sit comfortably in the Subhead. It might even have <strong>bold</strong> text. <a href="#">Click to learn more.</a> |
| 79 | +</p> |
| 80 | +``` |
| 81 | + |
| 82 | +You can add a button or something to the right of `.Subhead-heading` with the `.Subhead-actions` element. |
| 83 | + |
| 84 | +```html |
| 85 | +<div class="Subhead"> |
| 86 | + <div class="Subhead-heading">Subhead with button</div> |
| 87 | + <div class="Subhead-actions"><a href="#url" class="btn btn-sm btn-primary" role="button">Action</a></div> |
| 88 | +</div> |
| 89 | + |
| 90 | +<div class="Subhead Subhead--spacious"> |
| 91 | + <div class="Subhead-heading">Subhead with link</div> |
| 92 | + <div class="Subhead-actions"><a href="#url">Learn more</a></div> |
| 93 | +</div> |
| 94 | +``` |
| 95 | + |
| 96 | +Use all the elements together to create a Subhead with actions and a description. |
| 97 | + |
| 98 | +```html |
| 99 | +<div class="Subhead"> |
| 100 | + <div class="Subhead-heading">Subhead with actions and description</div> |
| 101 | + <div class="Subhead-actions"><a href="#url" class="btn btn-sm btn-primary" role="button">Action</a></div> |
| 102 | + <div class="Subhead-description">The subhead is a subdued header style with a light bottom border.</div> |
| 103 | +</div> |
| 104 | +``` |
| 105 | + |
| 106 | +Use the `.Subhead-heading--danger` modifier to make the text bold and red. This is useful for warning users. |
| 107 | + |
| 108 | +```html |
| 109 | +<div class="Subhead"> |
| 110 | + <div class="Subhead-heading Subhead-heading--danger">Danger zone</div> |
| 111 | +</div> |
| 112 | +``` |
| 113 | + |
| 114 | +<!-- %enddocs --> |
| 115 | + |
| 116 | +## License |
| 117 | + |
| 118 | +[MIT](./LICENSE) © [GitHub](https://github.com/) |
| 119 | + |
| 120 | +[primer-css]: https://github.com/primer/primer |
| 121 | +[docs]: http://primercss.io/ |
| 122 | +[npm]: https://www.npmjs.com/ |
| 123 | +[install-npm]: https://docs.npmjs.com/getting-started/installing-node |
| 124 | +[sass]: http://sass-lang.com/ |
0 commit comments