Subheading
is intended to be used as a heading for copy nested within a section. For example: a subheading under Contact may be Address or Phone number.
Import
import { Subheading } from '@contentful/f36-components';// orimport { Subheading } from '@contentful/f36-typography';
Examples
Basic
Margins
By default Subheading
component has a margin bottom of spacingM
(1rem
). You can override the default margin bottom by specifying it explicitly on the component level by marginBottom="none"
or any other value from our spacing options
as
property
By default Subheading
has an h3
tag. But you can change it be providing as
prop with values from h1
to h6
.
Truncated text
Sometimes you might have to truncate the text in the Subheading
component, so we provide the prop especially for that. Under the hood, what it does is add overflow: hidden
and set text-overflow
to ellipsis
. Have a look at the example below:
Composition
Props (API reference)
- Name
as
HTML Tag or React Component (e.g. div, span, etc) - Name
className
DescriptionCSS class to be appended to the root element
string - Name
isTruncated
falsetrue - Name
margin
Descriptionsets margin to one of the corresponding spacing tokens
"none""spacing2Xs""spacingXs""spacingS""spacingM""spacingL""spacingXl""spacing2Xl""spacing3Xl""spacing4Xl" - Name
marginBottom
Descriptionsets margin-bottom to one of the corresponding spacing tokens
"none""spacing2Xs""spacingXs""spacingS""spacingM""spacingL""spacingXl""spacing2Xl""spacing3Xl""spacing4Xl" - Name
marginLeft
Descriptionsets margin-left to one of the corresponding spacing tokens
"none""spacing2Xs""spacingXs""spacingS""spacingM""spacingL""spacingXl""spacing2Xl""spacing3Xl""spacing4Xl" - Name
marginRight
Descriptionsets margin-right to one of the corresponding spacing tokens
"none""spacing2Xs""spacingXs""spacingS""spacingM""spacingL""spacingXl""spacing2Xl""spacing3Xl""spacing4Xl" - Name
marginTop
Descriptionsets margin-top to one of the corresponding spacing tokens
"none""spacing2Xs""spacingXs""spacingS""spacingM""spacingL""spacingXl""spacing2Xl""spacing3Xl""spacing4Xl" - Name
testId
DescriptionA [data-test-id] attribute used for testing purposes
string