Skip to content
Cynosurev0.5.0
SearchStorybookGitHubnpmColour mode: System. Switch to Light

Components / Feedback and display

Heading

A section or page heading. level sets the element (h1 to h6) and size sets how it looks, so the page outline stays correct whatever the design asks for. For text that is not a heading, use Text.

Levels

When to useLink to "When to use"

  • A page title: level={1}, once per page. Add size="display" for a hero title.
  • A section or panel title: level from the page structure (a section inside a level 2 section is level 3), then size if the default looks too large or too small there.
  • A compact heading in dense UI: a small size with tone="muted", still at the right level.

Use something else when:

  • the text is not a heading (body copy, captions, labels): Text
  • it is rendered Markdown or other plain HTML: Prose, which styles the headings inside it
  • it is the title of an empty view with an icon and a next step: EmptyState
  • it labels a form control: Field

UsageLink to "Usage"

tsx
Copy
import { Heading } from "@arshad-shah/cynosure";

<Heading level={1}>Projects</Heading>
<Heading>Recent exports</Heading>
<Heading level={2} size="sm" tone="muted">Filters</Heading>
<Heading level={1} size="display" align="center">Capture anything</Heading>
<Heading level={3} truncate>{file.name}</Heading>

Level and sizeLink to "Level and size"

Without size, each level takes its own step of the type scale: level 1 is 2xl, 2 is xl, 3 is lg, 4 is md, 5 is sm and 6 is xs. Setting size changes the look only. Every heading below is an h3. display grows with the viewport and stays between 1.25 and 2 times 2xl.

Size is separate from level

Tone, weight and alignmentLink to "Tone, weight and alignment"

tone is neutral (the ink colour), muted, accent or inherit (the colour of whatever the heading sits in). weight is bold or medium. align is start, center or end. Left unset, the heading follows its parent's alignment.

TruncationLink to "Truncation"

truncate keeps the heading on one line and ends it with an ellipsis. A number cuts it after that many lines. Text that fits is left alone.

Truncation

PropsLink to "Props"

Every prop of Heading
PropWhat it doesTypeDefault
level
The element rendered (h1 to h6) and so the heading's place in the page outline. Default 2.HeadingLevel2
size
How large it looks, whatever its level. Defaults to the level's size: 1 is "2xl", 2 is "xl", 3 is "lg", 4 is "md", 5 is "sm" and 6 is "xs". "3xl" is 1.4 times "2xl" at every width; "display" is larger still and grows with the viewport, for a page's hero title.HeadingSize
tone
Text colour: the ink colour, muted, the accent, or whatever the parent uses. Default "neutral"."accent" | "neutral" | "inherit" | "muted""neutral"
weight
Font weight. Default "bold"."medium" | "bold""bold"
align
Text alignment, RTL aware. Left unset, it follows the parent."start" | "end" | "center"
truncate
true keeps it on one line and ends it with an ellipsis; a number cuts it after that many lines. Default false.number | booleanfalse
id
Set on the heading element, for aria-labelledby and links to the section.string
className
Added to the heading element, for layout.string
style
Layout only. Restyle through --cy-heading-* tokens.CSSProperties
children
The heading's text.ReactNode

Generated from the type definitions in @arshad-shah/cynosure 0.5.0.

Behaviour and accessibilityLink to "Behaviour and accessibility"

Heading is not interactive: it has no keyboard or pointer behaviour.

  • Outline: it renders a real h1 to h6, so it appears in the page outline and in screen reader heading lists at level. Choose the level from the page structure and the size from the design.
  • Naming a region: pass id and point aria-labelledby at it.
  • Truncated text: the full text stays the heading's accessible name.
  • Wrapping: lines are balanced (text-wrap: balance), and long words break instead of overflowing.
  • No margins: space headings with Stack or the layout around them.
  • Right to left: start and end swap sides, and a truncated heading keeps the start of its text.
  • Ref: the forwarded ref is the heading element.

TouchLink to "Touch"

Nothing in Heading is pressable, so it has no hit area.

ThemingLink to "Theming"

Tokens: --cy-heading-size-{xs,sm,md,lg,xl,2xl,display}, --cy-heading-font-family, --cy-heading-font-weight and --cy-heading-line-height.

Theming, table 1
TokenChangesFalls back to
--cy-heading-size-xs to --cy-heading-size-2xlFont size of each size--cy-font-size-xs to --cy-font-size-2xl
--cy-heading-size-displayFont size of size="display"5% of the viewport width, between 1.25 and 2 times --cy-font-size-2xl
--cy-heading-font-familyFont family--cy-font-display
--cy-heading-font-weightWeight of bold headings--cy-font-weight-bold
--cy-heading-line-heightLine height, as a number1.2
ts
Copy
createTheme({ components: { heading: { sizeXl: "1.5rem", "size-2xl": "2rem", lineHeight: "1.15" } } });
Tokens retune the scale

className and style are for layout only (margin, placement, width). Change the look through tokens so every product stays consistent.

Prose · Stack · EmptyState

These examples run Cynosure 0.5.0 (commit 50ce30b), the version on npm.

Getting started
Theming
Icons
Accessibility
Code editors and highlighters
Using Cynosure without React
Build-tool adapters
Components
Accordion
AppShell
AspectRatio
Breadcrumbs
Calendar
Card
Container
Disclosure
Divider
DocumentViewport
Grid
Inline
PageHeader
PanZoomCanvas
ScrollArea
SideNav
SortableList
SplitPane
Stack
StatusBar
Tabs
TitleBar
Toolbar
Tree
VirtualList
ZoomControls
Announcer
Avatar
Badge
CodeBlock
DescriptionList
EmptyState
ErrorBoundary
Field
Heading
IconTile
Image
Kbd
List
LoadingDots
Notice
ProgressBar
Prose
Skeleton
Stat
Steps
Table
Text
Button
Checkbox
Checklist
ColorField
ColorSwatches
Combobox
CompareSlider
CopyButton
DateField
FileDrop
IconButton
KeyValueEditor
Link
NumberField
Pagination
PathField
RadioGroup
SearchField
SegmentedControl
Select
SelectionFrame
SignaturePad
Slider
Switch
TagInput
TextArea
TextField
ThemeToggle
TimeField
ButtonBase
ChoiceBase
DialogBase
FileInputBase
HiddenValue
Icon
InputBase
LinkBase
LiveRegion
TextAreaBase
ChatMessage
Choice
DataGrid
DeviceFrame
HighlightedText
HotkeyField
ListRow
OptionList
OverlayFrame
QRCode
RowActions
Section
SiteFooter
SiteHeader
SkipLink
SortButton
VisuallyHidden
CommandPalette
ContextMenu
Dialog
FloatingToolbar
HoverCard
Menu
Menubar
Popover
ProgressOverlay
Sheet
Toast
Tooltip
Changelog