Heading
A typography primitive for ensuring consistent heading styles and hierarchy.
This component provides all relevant typographic styles such as font-family
,
line-height
and font-size
.
React
Heading composes Box
so you can use all the style props and add responsive
styles as well.
import { Heading } from '@hover/blueprint';
Size
To increase the visual size of the heading, use the size
props. This property
ensures that the heading size automatically adjusts for smaller screens.
Size Aliases
The Heading component now supports size aliases that match the text styles that design uses.
Semantic Size
An appropriate semantic heading tag is selected by default based on the size
prop, however it's often best to supply the as
prop explicitly to ensure the
correct semantic heading tag is used for the information hierarchy of a given
layout.
Size | Default as |
---|---|
200 | <h6> |
300 | <h5> |
400 | <h4> |
500 | <h3> |
600 | <h2> |
650 | <h2> |
700 | <h1> |
800 | <h1> |
900 | <h1> |
Truncation
If you'd like to truncate the heading after a specific number of lines, pass the
noOfLines
prop. This will render an ellipsis when the heading exceeds the
width of the viewport or maxWidth
prop.
Margin
The Heading presets come with a default margin-bottom
for separating the
heading from a sub-title or content. This is often note desired in flex or grid
based layouts. In that case, simply set noMargin
to disable the default
margin.
For editorial or otherwise block
content, the default margin should be used to
separate the Heading:
For other interfaces, the margin can be disabled to align things properly:
Capsize
Sometimes, in order to align text properly, it's necessary to do so based on the
height of the capital letters instead of the raw line-height
value. For these
cases, heading presets are available with a
Capsize adjustment so that the vertical
size of the text is aligned with its
cap height.
Pass withCapsize
to enable Capsize dimensions for Heading. Toggle the
checkboxes below to see the difference in layout.
Heading 900
Heading 800
Heading 700
Heading 650
Heading 600
Heading 500
Heading 400
Heading 300
Heading 200
Heading 100
Text Style
Capsize can also be applied via textStyle
:
Bootstrap
Bootstrap applies the appropriate styles to the <h1>
through <h6>
elements.
Heading Classes
The .h1
through .h6
classes are also available, for when you want to match
the font styling of a heading but cannot use the associated HTML element.