Heading
Installation
yarn add @spark-web/heading
Constrained, purposeful heading styles as a component.
Level
Controls the size of the heading and maps to the appropriate heading element
(h1
, h2
, h3
or h4
). The rendered element can be overridden with the as
prop.
Tone
Headings can be either "neutral" or "primary".
Alignment
Text can be aligned with the align
prop.
Truncation
Truncate text to a single line using the truncate
prop. Useful for displaying
user-generated content that may not fit within your layout.
Contrast
To ensure headings have sufficient contrast, when on a dark background the foreground colour is inverted.
Props
Prop | Type | Description |
---|---|---|
level | "1" | "2" | "3" | "4" | The heading level. |
align? | "left" | "center" | "right" | The horizontal alignment. |
children? | ReactNode: string | number | false | true | {} | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | The text content. |
data? | DataAttributeMap | Sets data attributes on the component. |
id? | string | An identifier which must be unique in the whole document. |
tone? | "neutral" | "muted" | "primary" | The tone of the text. |
truncate? | boolean | Truncate text to a single line. |
Extra props are passed into the underlying Box
component.