Typography

Typography

Renders text using the Hub type scale, pulling font family, weight, size, line height, and letter spacing from tokens. The color prop takes Figma-style token paths that mirror the design variables, with legacy semantic aliases kept for back-compat.

Examples

Scale
Loading preview
<Typography variant="h4">Heading</Typography>
<Typography variant="body1">Body copy</Typography>
<Typography variant="caption" color="text/secondary">Caption</Typography>
Token-path colors
Loading preview
<Typography color="secondary/main">Brand</Typography>
<Typography color="error/main">Error</Typography>
<Typography color="success/main">Success</Typography>
Any token as a text color
Loading preview
<Typography variant="body2" color="neutral/500">off-spec grey note</Typography>
Legacy aliases still work
Loading preview
// brand resolves to secondary/main; prefer the token path in new code
<Typography variant="h4" color="brand">Upgrade to Pro</Typography>

API

PropTypeDefaultDescription
variant'display' | 'h1'..'h6' | 'bodyLarge' | 'body1' | 'body2' | 'caption' | 'label' | 'labelSmall' | 'code'body1Text style variant.
color'inherit' | 'text/primary' | 'text/secondary' | 'text/disabled' | '{primary|secondary|error|warning|success|info}/{main|light|dark|contrast}' | 'neutral/100'..'neutral/900' | aliases 'primary' | 'secondary' | 'muted' | 'danger' | 'warning' | 'success' | 'brand'inheritText color. Prefer a Figma-style token path (text/primary, secondary/main = brand yellow, neutral/500, error/main), which maps 1:1 to the Figma variable. Legacy aliases still work: primary/secondary are the text colors, muted=text/disabled, danger=error/main, brand=secondary/main. Typed union, so autocomplete and typo-safety hold and raw hex is rejected.
align'left' | 'center' | 'right'noneHorizontal alignment.
truncate / lineClampboolean / numbernoneSingle-line or N-line ellipsis.

Styling and attributes

Like every component, Typography accepts the universal token style props (m, p, sx, display, responsive maps, ...) and forwards standard DOM attributes (id, data-*, aria-*, event handlers) to the underlying element. See Styling for the full API.

Guidelines

Do

  • Prefer token paths (text/secondary, secondary/main) so code matches the Figma variable names.
  • Use secondary/main (brand yellow) for emphasis on dark surfaces only; it fails contrast on light.
  • Reach for any token as a text color directly, e.g. color="neutral/500"; no style override needed.

Avoid

  • Do not use the MUI palette props (sx, fontWeight); this is the agnostic Hub API.
  • Do not confuse text/secondary (grey) with secondary/main (brand yellow); they are different values.
  • Do not hardcode a hex; pass a token-path color so it stays themable.

Import from @hub/ds-components. Interactive playground: Storybook. Figma Code Connect node 224-163.