Our standard heading component. Headings have no margins by default and can be sized independently of the underlying html element.
npm install @nib-components/heading
import Heading from '@nib-components/heading';
|number or object||The heading size. Can be made responsive by passing an object of breakpoints. Value(s) must be one of |
|string or Component||The heading component. What DOM element should your heading be. Optional if |
|string or function||The heading color. Can be any of the named color tokens or theme selectors.|
|string||Dependent on ||Switches the font-family for the heading. This only works with the |
|string or object||Set the alignment of the text. Can be made responsive by passing an object of breakpoints. Values must be one of |
The Heading component should be used for all heading elements and headings should be sentence case only.
There should only ever be one
h1 used on a page.
Be sure not to exceed 70 characters and avoid using hyphens (
-) to line wrap text.
The Heading component supports our two brand fonts; Grenette Pro (serif) and Buenos Aires (sans-serif). The default value for font type is dependent on the
size of the heading.
Grenette Pro should be used almost exclusively for large headinngs. It should be used only for page or section headings, or where nib's brand voice is used to communicate a value proposition. See our foundational typography guidelines for more information.
The variable default for
fontType dependent on the
size of the heading can lead to unexpected font-swap in one specific scenario: Commonly, a heading size of
1 is dropped down to a
2 on mobile devices to save space. In this case, the heading font will be sans-serif on mobile, and serif above the
To prevent this swapping, add an explicit
Headings have no margins by default. To add margins to paragraphs please use our Stack layout component for consistent vertical spacing.
There are times when you may want to include a certain
h level, but for the underlying DOM element to have a specific size. For this, our Heading component supports mixing styling and heading levels through the
This is especially important for ensuring that pages follow a logical, semantic heading hierarchy.
Responsive heading size is possible by supplying an object of breakpoints to the
size prop, and specifying the underlying DOM element via the
If longer text is required, consider using the Copy component instead.