Typography
Headings and paragraphs in the site's type scale, for JSX and for MDX. Each part reads a type-role token, so a site sets its own scale in CSS and the markup stays the same.
When to use
- Show a page title, a section heading, or a paragraph of copy in the site's type scale.
- Render the
h1toh6andpelements of MDX content: map each element to its part in your MDXcomponents, as this docs site does. - Prefer
Card.TitlefromCardfor the title of a card. - Prefer
Dialog.TitlefromDialogfor the title of a dialog. - Prefer
Codefor a fragment of code.
Headings
Typography.H1 through Typography.H6 each render the heading element of their name. By default they use the text-heading-5xl, 3xl, 2xl, xl, base, and xs steps, the same steps as Tailwind's text-* scale. Typography.H6 is also uppercase with wide letter spacing.
Another size
The part sets the level in the document outline, and the step sets its size. To give a heading another size, pass a heading step in className, from text-heading-xs to text-heading-8xl. Your class replaces the part's own step. To change only the line height, add a leading-* class, such as text-heading-xl leading-8. Do not use the slash form text-heading-xl/8: Tailwind then sets only the size and the line height, so the heading loses the weight and letter spacing of its step.
Lead paragraph
Pass text-paragraph-lg to Typography.P for the lead paragraph under a page title. Pass text-paragraph-sm for dense copy.
A scale for one section
The type roles are CSS variables, so any element can set a different scale for the parts inside it. Set every sub-key of a step you change: a sub-key you leave out keeps the site's value. To set the scale for a whole site, see Typography.
Composition
The parts are siblings: none of them wraps another, so the namespace has no Root. Use each one where its element goes.
Polymorphism
Every Typography part accepts an asChild prop. When true, the part renders its single child instead of its default element, and forwards its class names, data-* attributes, and ref onto that child. Use it on Typography.P to give a figcaption or a blockquote the paragraph style. Keep a heading part on a heading element, so the document outline stays correct.
API Reference
Typography.H1
A level-one heading, in the text-heading-5xl step by default. Renders an h1.
All props from h1, plus:
Typography.H2
A level-two heading, in the text-heading-3xl step by default. Renders an h2.
All props from h2, plus:
Typography.H3
A level-three heading, in the text-heading-2xl step by default. Renders an h3.
All props from h3, plus:
Typography.H4
A level-four heading, in the text-heading-xl step by default. Renders an h4.
All props from h4, plus:
Typography.H5
A level-five heading, in the text-heading-base step by default. Renders an h5.
All props from h5, plus:
Typography.H6
A level-six heading, in the text-heading-xs step by default, in uppercase with wide letter spacing. Renders an h6.
All props from h6, plus:
Typography.P
A paragraph in the text-paragraph-base step and the body text color. Renders a p.
All props from p, plus: