Typography
A polymorphic text component for consistent headings, paragraphs, lead text, and inline code styling.
This is a default paragraph typography rendering. It uses the default font size, line height, and paragraph spacing.
1'use client';23import { Typography } from '@/components/ui/typography';45export function Default() {6 return (7 <Typography variant="p">8 This is a default paragraph typography rendering. It uses the default font size, line height,9 and paragraph spacing.10 </Typography>11 );12}
Installation
pnpm dlx nachui add typography
Anatomy
1import { Typography } from '@/components/ui/typography';
1<Typography variant="h1">Hello World</Typography>2<Typography variant="p">Body copy goes here.</Typography>3<Typography variant="muted">De-emphasized text.</Typography>
Examples
Default
This is a default paragraph typography rendering. It uses the default font size, line height, and paragraph spacing.
1'use client';23import { Typography } from '@/components/ui/typography';45export function Default() {6 return (7 <Typography variant="p">8 This is a default paragraph typography rendering. It uses the default font size, line height,9 and paragraph spacing.10 </Typography>11 );12}
Headings
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
1'use client';23import { Typography } from '@/components/ui/typography';45export function Headings() {6 return (7 <div className="flex w-full flex-col gap-4">8 <Typography variant="h1">Heading 1</Typography>9 <Typography variant="h2">Heading 2</Typography>10 <Typography variant="h3">Heading 3</Typography>11 <Typography variant="h4">Heading 4</Typography>12 <Typography variant="h5">Heading 5</Typography>13 <Typography variant="h6">Heading 6</Typography>14 </div>15 );16}
Lead, Large & Muted
Lead Text
A tall paragraph text style designed to introduce an article or section.
Large Text
Slightly larger copy designed for subheaders, callouts, or featured content.
Small & Muted Text
De-emphasized descriptive text, perfect for captions or legal copy.
1'use client';23import { Typography } from '@/components/ui/typography';45export function LeadMuted() {6 return (7 <div className="flex w-full flex-col gap-4">8 <div>9 <Typography10 variant="small"11 className="text-primary mb-1 block font-bold tracking-wider uppercase"12 >13 Lead Text14 </Typography>15 <Typography variant="lead">16 A tall paragraph text style designed to introduce an article or section.17 </Typography>18 </div>1920 <div>21 <Typography22 variant="small"23 className="text-primary mb-1 block font-bold tracking-wider uppercase"24 >25 Large Text26 </Typography>27 <Typography variant="large">28 Slightly larger copy designed for subheaders, callouts, or featured content.29 </Typography>30 </div>3132 <div>33 <Typography34 variant="small"35 className="text-primary mb-1 block font-bold tracking-wider uppercase"36 >37 Small & Muted Text38 </Typography>39 <Typography variant="muted">40 De-emphasized descriptive text, perfect for captions or legal copy.41 </Typography>42 </div>43 </div>44 );45}
Polymorphic (as prop)
Paragraph rendered as Span
This uses paragraph styling but is rendered as a inline `span` tag in the DOM.Heading rendered as Div
Code block rendering
console.log("This automatically renders as a code tag by variant inference");1'use client';23import { Typography } from '@/components/ui/typography';45export function CustomTag() {6 return (7 <div className="flex w-full flex-col gap-6">8 <div>9 <Typography10 variant="small"11 className="text-primary mb-1 block font-bold tracking-wider uppercase"12 >13 Paragraph rendered as Span14 </Typography>15 <Typography as="span" variant="p" className="bg-secondary/20 rounded p-2">16 This uses paragraph styling but is rendered as a inline `span` tag in the DOM.17 </Typography>18 </div>1920 <div>21 <Typography22 variant="small"23 className="text-primary mb-1 block font-bold tracking-wider uppercase"24 >25 Heading rendered as Div26 </Typography>27 <Typography as="div" variant="h3">28 This looks like an H3, but it's actually a `div` element.29 </Typography>30 </div>3132 <div>33 <Typography34 variant="small"35 className="text-primary mb-1 block font-bold tracking-wider uppercase"36 >37 Code block rendering38 </Typography>39 <Typography variant="code">40 console.log("This automatically renders as a code tag by variant inference");41 </Typography>42 </div>43 </div>44 );45}
API Reference
Typography
| Prop | Type | Default | Description |
|---|---|---|---|
variant | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p' | 'blockquote' | 'lead' | 'large' | 'small' | 'muted' | 'code' | 'p' | Text style variant |
as | React.ElementType | - | Override the rendered HTML element |
align | 'left' | 'center' | 'right' | 'justify' | - | Text alignment |
weight | 'light' | 'normal' | 'medium' | 'semibold' | 'bold' | 'extrabold' | - | Font weight override |
className | string | - | Additional CSS classes |
Found something to improve?
Notice a bug, typo, or missing detail on this page? Help us make the documentation better by opening a GitHub issue.