Skip to content

Heading

Semantic heading with decoupled level and visual size so document outline and typography scale independently.

  • stable
  • since v0.1.0
  • 4.41 kB
  • typography
  • primitive

Renders <h1><h6> based on the level prop; size is purely visual so structural hierarchy stays correct even when designs diverge from the heading scale.

Preview
Open
tsx

Use level to set the rendered tag (16). When size is omitted the visual scale defaults to the matching heading composite token, so a level={2} heading looks like an h2 out of the box.

Preview
Open
tsx

Nine sizes are exposed — xs, sm, md, lg, xl, 2xl, 3xl, 4xl, 5xl. Pair a small size with a high level to keep semantics intact while shrinking the type scale, or vice versa.

Preview
Open
tsx

Override the default weight from the heading token with regular, medium, semibold, or bold.

Preview
Open
tsx

Pass truncate for ellipsis on one line or a number for multi-line clamp — handy for card titles inside fixed layouts.

Preview
Open
tsx
PropTypeDefaultDescription
level
1|2|3|4|5|6
2
Semantic heading level — renders `h1`..`h6` for document outline / SEO. Use this to fix the structural level; pair with `size` to tune visuals.
size
Responsive<HeadingSize>
Visual type-scale step. Decoupled from `level` so visual hierarchy can diverge from semantic hierarchy. Falls back to the level-matched token.
weight
Responsive<HeadingWeight>
Override the level's default font weight.
align
Responsive<HeadingAlign>
Horizontal text alignment.
truncate
number|boolean
`true` → single-line truncation; `number > 1` → multi-line line-clamp.
className
string
Additional class names appended after Cynosure's base classes.
style
CSSProperties
Inline style overrides merged last.
children
ReactNode
Heading text content.
padding
Padding on all four sides. Token from the spacing scale.
paddingX
Horizontal padding (left + right). Overrides `padding` on the X axis.
paddingY
Vertical padding (top + bottom). Overrides `padding` on the Y axis.
paddingTop
Padding on the top edge. Beats `padding` / `paddingY`.
paddingRight
Padding on the right (inline-end in RTL) edge.
paddingBottom
Padding on the bottom edge.
paddingLeft
Padding on the left (inline-start in RTL) edge.
margin
Margin on all four sides. Accepts the spacing scale or `"auto"`.
marginX
Horizontal margin (left + right). Use `"auto"` to centre.
marginY
Vertical margin (top + bottom).
marginTop
Margin on the top edge.
marginRight
Margin on the right edge.
marginBottom
Margin on the bottom edge.
marginLeft
Margin on the left edge.
width
Element width. Accepts a `SpaceToken`, `LengthValue`, or named alias.
height
Element height. Accepts a `SpaceToken`, `LengthValue`, or named alias.
minWidth
Minimum width — useful for preventing flex children from collapsing.
maxWidth
Maximum width — `"prose"` caps to a comfortable reading measure.
minHeight
Minimum height.
maxHeight
Maximum height.
background
Background colour. Use a `ColorToken` like `"bg.surface"` for theme awareness.
color
Text colour. Inherits unless set.
borderColor
Border colour. Pair with `borderWidth` to make the border visible.
borderWidth
Border thickness in scale steps.
borderStyle
Border line style.
borderRadius
Corner rounding token.
boxShadow
Drop-shadow token from the elevation scale.
opacity
Responsive<number | `${number}`>
Opacity 0–1. Use sparingly — prefer surface tokens over translucency.
overflow
How content that exceeds the box is handled.
overflowX
Horizontal-axis overflow control. Overrides `overflow` for the X axis.
overflowY
Vertical-axis overflow control.
display
CSS `display` value. `"contents"` removes the element's box from layout.
position
CSS `position`. Pair with `top`/`right`/`bottom`/`left` for placement.
top
Top inset (when positioned). Accepts a `SpaceToken`, `"auto"`, `"0"`, or `LengthValue`.
right
Right inset (when positioned).
bottom
Bottom inset (when positioned).
left
Left inset (when positioned).
zIndex
Stacking-context layer token (`"modal"`, `"tooltip"`, …).
gridColumn
Responsive<string>
Grid-column shorthand (e.g. `"1 / 3"`, `"span 2"`).
gridRow
Responsive<string>
Grid-row shorthand.
gridArea
Responsive<string>
Named grid area.
flex
Responsive<"1" | "none" | "auto" | "initial" | (string & {})>
Shorthand: `1 | auto | none | initial | <css>`. Resolves to `flex` on the child.
flexGrow
Responsive<number | `${number}`>
Grow factor inside a flex container.
flexShrink
Responsive<number | `${number}`>
Shrink factor inside a flex container.
flexBasis
Responsive<"content" | SizeValue>
Initial main-axis size before grow/shrink.
alignSelf
Override `align-items` for a single child.
justifySelf
Override `justify-items` for a single child (grid).
order
Responsive<number | `${number}`>
Flex/grid child reorder index.
asChild
boolean
When `true`, renders the primitive's single React child via `Slot`, forwarding className/style/ref/event handlers onto it.
  • level always controls the rendered element so the document outline stays correct for screen readers and SEO.
  • Decouple size from level to keep visual hierarchy flexible without skipping headings (don’t jump from h1 to h4 just to shrink type).
  • One h1 per page; reach for level={2} or deeper inside sections.
  • truncate hides overflow visually only — keep the full heading in the DOM so assistive tech receives it.
  • Maintain enough contrast between heading colour and background; large weights still need to pass WCAG large-text minimums.
  • Pair Heading with Text variant="lead" directly underneath for a familiar title + lede pattern.
  • Use align="center" for hero headings and align="start" (default) for body sections.
  • Combine a small Text variant="overline" above a Heading for a section eyebrow without losing semantics.
  • Use asChild to project Heading typography onto a link wrapper for clickable card titles.