structyl

Typography

stable

Theme-aware text styles.

Basic usage

Heading

Supporting text

Examples

Text scale

Typography gives common headings and body text a consistent rhythm.

Build components faster

Compose primitives with Tailwind tokens.

Muted copy for supporting context.

Inline code

Use the code variant for short tokens and prop names.

Set defaultOpen for uncontrolled components.

Text props

The supported typography props cover variants, alignment, color and spacing.

Overline
Centered heading

This line is intentionally long and will truncate.

Heading and body variants

Typography supports 24 named variants with automatic element mapping.

h1 Heading

h2 Heading

h3 Heading

h4 Heading

h5 Heading
h6 Heading
subtitle1 — secondary info
subtitle2 — label-weight text

body1 — the default paragraph style

body2 — smaller body copy

caption — metadata and timestampsoverline — section category

Semantic colors

Use the color prop to apply semantic text colors inline.

color="inherit" — The quick brown fox jumps over the lazy dog.

color="primary" — The quick brown fox jumps over the lazy dog.

color="secondary" — The quick brown fox jumps over the lazy dog.

color="error" — The quick brown fox jumps over the lazy dog.

color="warning" — The quick brown fox jumps over the lazy dog.

color="info" — The quick brown fox jumps over the lazy dog.

color="success" — The quick brown fox jumps over the lazy dog.

color="disabled" — The quick brown fox jumps over the lazy dog.

Utility props

gutterBottom, noWrap, truncate, and paragraph control spacing and overflow.

gutterBottom adds margin below

noWrap — This very long line of text will not wrap to the next line even though the container is narrow

truncate — This very long line of text will be cut off with an ellipsis when it overflows

paragraph — Adds a bottom margin like a paragraph element would have.

Features

  • Heading and body variants.
  • Token-based colors.

Installation

bash
pnpm dlx structyl add typography

API Reference

Typography

Text variants and text behavior.

PropTypeDefault
variant'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'subtitle1' | 'subtitle2' | 'body1' | 'body2' | 'body' | 'small' | 'caption' | 'button' | 'overline' | 'muted' | 'code'

Text style.

'body'
align'inherit' | 'left' | 'center' | 'right' | 'justify'

Text alignment.

color'default' | 'inherit' | 'primary' | 'secondary' | 'success' | 'warning' | 'destructive' | 'muted'

Tokenized text color.

'default'
gutterBottomboolean

Add bottom margin.

false
noWrapboolean

Truncate long text on one line.

false
paragraphboolean

Display as paragraph-like block spacing.

false
classNamestring

Additional Tailwind classes merged with the component defaults.

Typography | structyl