Typography
Styles for headings, paragraphs, lists and more.
When to Use
Use Typography components when you need to:
- Establish a clear content hierarchy with semantic headings (H1-H4)
- Render long-form body text with consistent line-height and spacing
- Display quotations with styled blockquotes
- Present structured data in typography-styled tables
- Show bulleted lists with uniform item spacing
- Highlight code references inline within prose
- Apply text variants (Lead, Large, Small, Muted) for visual emphasis
When Not to Use
- Complex data tables with sorting, filtering, or pagination — use Data Table or Table
- Status labels or category tags — use Badge
- Multi-line code blocks or syntax-highlighted snippets — use a dedicated code block component
- Visual dividers between sections — use Separator
- Content inside cards that already defines its own text styles — use Card sub-components directly
Full Demo
A complete example showing all typography elements working together. The "Joke Tax Chronicles" story demonstrates headings, paragraphs, blockquotes, tables, and lists in context.
Taxing Laughter: The Joke Tax Chronicles
Once upon a time, in a far-off land, there was a very lazy king who spent all day lounging on his throne. One day, his advisors came to him with a problem: the kingdom was running out of money.
The King's Plan
The king thought long and hard, and finally came up with a brilliant plan: he would tax the jokes in the kingdom.
“After all,” he said, “everyone enjoys a good joke, so it's only fair that they should pay for the privilege.”
The Joke Tax
The king's subjects were not amused. They grumbled and complained, but the king was firm:
- 1st level of puns: 5 gold coins
- 2nd level of jokes: 10 gold coins
- 3rd level of one-liners: 20 gold coins
As a result, people stopped telling jokes, and the kingdom fell into a gloom. But there was one person who refused to let the king's foolishness get him down: a court jester named Jokester.
Jokester's Revolt
Jokester began sneaking into the castle in the middle of the night and leaving jokes all over the place: under the king's pillow, in his soup, even in the royal toilet. The king was furious, but he couldn't seem to stop Jokester.
And then, one day, the people of the kingdom discovered that the jokes left by Jokester were so funny that they couldn't help but laugh. And once they started laughing, they couldn't stop.
The People's Rebellion
The people of the kingdom, feeling uplifted by the laughter, started to tell jokes and puns again, and soon the entire kingdom was in on the joke.
| King's Treasury | People's Happiness |
|---|---|
| Empty | Overflowing |
| Modest | Satisfied |
| Full | Ecstatic |
The king, seeing how much happier his subjects were, realized the error of his ways and repealed the joke tax. Jokester was declared a hero, and the kingdom lived happily ever after.
The moral of the story is: never underestimate the power of a good laugh and always be careful of bad ideas.
Headings
Four levels of headings (H1-H4) with consistent styling. H1 uses scroll-margin, text-balance, and extrabold weight. H2 includes a bottom border.
The Joke Tax Chronicles
The People of the Kingdom
The Joke Tax
People stopped telling jokes
Paragraph
Standard paragraph text with leading-7 line height. Consecutive paragraphs automatically receive top margin via the :not(:first-child) selector.
The king, seeing how much happier his subjects were, realized the error of his ways and repealed the joke tax. Jokester was declared a hero, and the kingdom lived happily ever after.
The moral of the story is: never underestimate the power of a good laugh and always be careful of bad ideas.
Blockquote
Styled blockquote with a 2px left border, left padding, and italic text for quotations or callouts.
“After all,” he said, “everyone enjoys a good joke, so it's only fair that they should pay for the privilege.”
Table
Typography-styled table with header, body, bordered cells, and alternating row colors via even:bg-muted. Wrapped in a scrollable container for overflow.
| King's Treasury | People's Happiness |
|---|---|
| Empty | Overflowing |
| Modest | Satisfied |
| Full | Ecstatic |
List
Unordered list with disc markers, left margin, and consistent item spacing via [&>li]:mt-2.
- 1st level of puns: 5 gold coins
- 2nd level of jokes: 10 gold coins
- 3rd level of one-liners: 20 gold coins
Inline Code
Monospace-styled inline code element with a muted background, rounded corners, and semibold weight for referencing code within text.
The @radix-ui/react-alert-dialog component is used for critical confirmations. You can also use npm install to add packages.
Text Variants
Additional text styles: Lead (larger intro text in muted-foreground), Large (semibold, slightly larger), Small (compact, medium weight), and Muted (de-emphasised helper text).
A modal dialog that interrupts the user with important content and expects a response.
Enter your email address.
UX & Design Guidelines
Visual Hierarchy
Use heading levels sequentially (H1 → H2 → H3 → H4) to establish a clear content hierarchy. Each page should have exactly one TypographyH1. Pair headings with TypographyLead for introductory paragraphs that provide context below page titles.
Spacing & Layout
Typography components include built-in spacing via scroll-m-20 on headings and mt-6 on paragraphs. Avoid adding extra wrapper margins that conflict with these defaults. For article-style layouts, wrap content in a max-w-prose container for optimal line length (roughly 65 characters per line).
Responsive Behavior
TypographyH1 scales from text-4xl to lg:text-5xl for larger screens and uses text-balance for better line wrapping. Typography tables are wrapped in an overflow container so they scroll horizontally on narrow viewports rather than breaking the layout.
Color & Contrast
Headings and body text use text-foreground for maximum readability. De-emphasised text such as TypographyMuted and TypographyLead use text-muted-foreground, which meets WCAG 2.1 AA contrast requirements against both light and dark backgrounds. Inline code uses bg-muted for subtle visual distinction.
Accessibility
Semantic Structure
- Each heading component renders its native HTML element (
<h1>through<h4>), creating an accessible document outline for screen readers - Never skip heading levels (e.g., H1 → H3) — this breaks the heading hierarchy that assistive technologies rely on for page navigation
TypographyBlockquoterenders a<blockquote>element, announced by screen readers as a quotationTypographyListrenders a<ul>element; screen readers announce the number of items
Screen Reader Support
- Headings are navigable via the screen reader's heading navigation shortcuts (e.g., H in NVDA/JAWS)
TypographyInlineCoderenders as<code>, which some screen readers announce as "code" before the content- Table components use proper
<thead>,<th>, and<td>elements so screen readers can announce row/column headers when navigating cells - Add a
<caption>(visible orsr-only) to tables for additional context
Keyboard Navigation
- Headings with
scroll-m-20provide proper scroll margin when navigated to via anchor links, preventing content from hiding behind sticky headers - Tab navigation skips non-interactive typography elements as expected; only links within text are focusable
- Table cells can be navigated with arrow keys when using screen reader table navigation mode
ARIA Attributes
{/* Headings create an accessible document outline */}
<TypographyH1>Page Title</TypographyH1>
<TypographyH2>Section Title</TypographyH2>
{/* Blockquote with attribution */}
<figure>
<TypographyBlockquote>
"Everyone enjoys a good joke."
</TypographyBlockquote>
<figcaption className="text-sm text-muted-foreground mt-2">
— The King
</figcaption>
</figure>
{/* Table with caption for context */}
<TypographyTable>
<caption className="sr-only">
Joke tax rates by category
</caption>
<TypographyThead>
<TypographyTr>
<TypographyTh scope="col">Category</TypographyTh>
<TypographyTh scope="col">Rate</TypographyTh>
</TypographyTr>
</TypographyThead>
...
</TypographyTable>
{/* Inline code with lang attribute for screen readers */}
<TypographyInlineCode lang="en">npm install</TypographyInlineCode>Related Components
Card
Container with header, content, and footer for grouping related typography and interactive elements.
Badge
Small status labels and tags when inline code or text variants are not sufficient.
Separator
Visually or semantically divides sections of typographic content.
Table
Full-featured data table when you need sorting, selection, or pagination beyond typography tables.
API Reference
All typography components accept their native HTML attributes in addition to the props listed below.
TypographyH1 / H2 / H3 / H4
Renders semantic heading elements with consistent tracking and scroll margin.
| Prop | Type | Default | Description |
|---|---|---|---|
| childrenrequired | React.ReactNode | — | The content to render inside the heading element. |
| className | string | — | Additional CSS classes to merge with the default heading styles. |
| asChild | boolean | false | When true, renders children as the root element, merging props. Useful for rendering headings as links or other elements. |
TypographyP
Standard paragraph with leading-7 and automatic top margin for siblings.
| Prop | Type | Default | Description |
|---|---|---|---|
| childrenrequired | React.ReactNode | — | The content to render inside the paragraph. |
| className | string | — | Additional CSS classes. Default styles include leading-7 and automatic top margin for siblings. |
TypographyBlockquote
Styled blockquote with left border and italic text.
| Prop | Type | Default | Description |
|---|---|---|---|
| childrenrequired | React.ReactNode | — | The quoted content to render inside the blockquote. |
| className | string | — | Additional CSS classes. Default styles include left border, padding, and italic text. |
TypographyTable / Thead / Tbody / Tr / Th / Td
Composable table elements with borders, padding, and alternating row colors.
| Prop | Type | Default | Description |
|---|---|---|---|
| childrenrequired | React.ReactNode | — | Table content (TypographyThead, TypographyTbody). |
| className | string | — | Additional CSS classes. The table is wrapped in a scrollable container by default. |
TypographyList
Unordered list with disc markers and consistent item spacing.
| Prop | Type | Default | Description |
|---|---|---|---|
| childrenrequired | React.ReactNode | — | List items (<li> elements) to render. |
| className | string | — | Additional CSS classes. Default styles include disc markers and item spacing. |
TypographyInlineCode
Monospace inline code with muted background and rounded corners.
| Prop | Type | Default | Description |
|---|---|---|---|
| childrenrequired | React.ReactNode | — | The code text to display inline. |
| className | string | — | Additional CSS classes. Default styles include monospace font, muted background, and rounded corners. |
TypographyLead / Large / Small / Muted
Text variants for different emphasis levels. Lead and Muted render <p>, Large renders <div>, Small renders <small>.
| Prop | Type | Default | Description |
|---|---|---|---|
| childrenrequired | React.ReactNode | — | The text content to render. |
| className | string | — | Additional CSS classes to merge with the variant styles. |
Available Components
Import individual components or use the Typography namespace object.
Headings
TypographyH1TypographyH2TypographyH3TypographyH4
Content
TypographyPTypographyBlockquoteTypographyListTypographyInlineCode
Table
TypographyTableTypographyTheadTypographyTbodyTypographyTrTypographyThTypographyTd
Variants
TypographyLeadTypographyLargeTypographySmallTypographyMuted