Heading
Page and section headings, matching the HTML ones. Wrap them in `Section` so the levels stay right when components nest.
compliant
- Overview
- Props
- Figma
Use the Section component to automatically manage heading levels in your component hierarchy. It ensures proper semantic HTML structure, improves accessibility for screen reader users, and eliminates the mental overhead of manually tracking heading levels across nested components.
Usage​
Heading 1
Heading 2
Heading 3
Size​
You can change Heading's size independently of its level:
- If you only set the
level, it will automatically deduce thesize - If you also specify the
size, it will use that value instead
Medium heading with h5 semantics
Accessibility​
More details in the dedicated section Headings.
Testing with VoiceOver​
On macOS, activate VoiceOver (Cmd + F5) And navigate to the next or previous heading using Ctrl + Option + Cmd + H and Ctrl + Option + Cmd + Shift + H, respectively.
Playground​
murray and murray/mobile.Heading props
| Name | Type | Default Value | Description | Usage count |
|---|---|---|---|---|
| align | 9 possibilities"unset""left""right""end""start""auto""center""justify"undefined | |||
| aria-disabled | booleanundefined | |||
| aria-label | stringundefined | |||
| aria-level | numberundefined | Heading level when paired with `role="heading"`. | ||
| asChild | 5 possibilitiesboolean"web""except-style""except-style-web"undefined | |||
| className | stringundefined | |||
| color | 4 possibilitiesundefined`$${string}`Variable<any>OpaqueColorValue | Color prop accepts Tamagui color tokens, ColorTokens, or dynamic token strings. Examples: "$grey900", "$indigo500", "$white", or dynamically constructed tokens like `$${name}900` | ||
| dir | "auto"Directionundefined | |||
| ellipsizeMode | "head""middle""tail""clip"undefined | |||
| fontFamily | FontTokensundefined | |||
| htmlFor | stringundefined | |||
| id | stringundefined | |||
| italic | booleanundefined | |||
| lang | LocaleOrLanguageundefined | |||
| level | 7 possibilities"h1""h2""h3""h4""h5""h6"undefined | Hierarchical level of the heading | ||
| maxFontSizeMultiplier | numbernullundefined | |||
| numberOfLines | numberundefined | |||
| onFocus | undefinedFocusEventHandler<HTMLDivElement> | |||
| onKeyDown | ((e: KeyboardEvent) => void)undefined | |||
| onLayout | ((e: LayoutChangeEvent) => void)undefined | |||
| onPress | 3 possibilities((event: GestureResponderEvent) => void)nullundefined | |||
| onTextLayout | 2 possibilitiesundefined(e: NativeSyntheticEvent<TextLayoutEventData>) => void | Fires on mobile with the list of rendered lines. Passes through to the underlying RN Text. | ||
| role | Roleundefined | |||
| size* | 7 possibilities"xs""sm""md""lg""xl""xxl"MediaProps<"xs" | "sm" | "md" | "lg" | "xl" | "xxl"> | Visual size Use design tokens to set the font size and line height. - `xs` (16px / 24px) - `sm` (18px / 28px) - `md` (24px / 32px) - `lg` (32px / 40px) - `xl` (40px / 48px) - `xxl` (56px / 64px) | ||
| sx | 2 possibilitiesundefinedOmit<TextProps, "fontStyle" | "fontFamily" | "fontWeight"> | |||
| tabIndex | stringnumberundefined | |||
| transform | 6 possibilities"none""capitalize""uppercase""lowercase""unset"undefined | |||
| weight | TextWeightundefined |
Undocumented props
| Name | Type | Default Value | Description | Usage count |
|---|---|---|---|---|
| css | any | |||
| onClick | any |
Style API​
Use sx for one-off adjustments. It accepts these style keys:
Each can be overridden per breakpoint with: