Typography
Text styles for headings, paragraphs, links, and inline code with WCAG 2.2 AA contrast compliance.
Installation
npx vayu-ui init #one time onlynpx vayu-ui add typographynpx vayu-ui add -t typographyUsage
Headings
Heading 1 - Main Title
Heading 2 - Section Title
Heading 3 - Subsection
Heading 4 - Component
Heading 5 - Subcomponent
Heading 6 - Minor Heading
Paragraphs
This is a paragraph example. It has a relaxed line height and proper spacing for optimal readability. Typography is the art and technique of arranging type to make written language legible, readable, and appealing when displayed.
This is a secondary paragraph. It uses muted-content color to indicate less emphasis in the visual hierarchy.
Text Components
user@example.com
Inline code example: npm install vayu-ui
With language hint: const x: string = "hello"
Internal link (Next.js Link):
Go to ComponentsExternal link (opens in new tab):
External link with icon✨ This is a Call to Action text
Color Variants
Error text variant
destructive token
Success text variant
success token
Warning text variant
warning token
Info text variant
info token
Gradient Heading Effect
brand gradient
Font Variants
Primary font (Oswald) - for headings
Secondary font (Mulish) - for body text
<Typography.H1>Main Heading</Typography.H1>
<Typography.H2>Section Title</Typography.H2>
<Typography.H3>Subsection</Typography.H3>
<Typography.H4>Component Heading</Typography.H4>
<Typography.H5>Subcomponent Heading</Typography.H5>
<Typography.H6>Minor Heading</Typography.H6>
<Typography.P>Default paragraph with relaxed line height.</Typography.P>
<Typography.P variant="secondary">Secondary paragraph for less emphasis.</Typography.P>
<Typography.Label htmlFor="email">Email Address</Typography.Label>
<Typography.Code>npm install vayu-ui</Typography.Code>
<Typography.Code codeLang="typescript">const x: string = "hello"</Typography.Code>
<Typography.Link href="/components">Internal Link</Typography.Link>
<Typography.Link href="https://example.com" target="_blank">
External Link
</Typography.Link>
<Typography.CTA className="text-brand">Call to Action</Typography.CTA>
<Typography.P variant="error">Error text</Typography.P>
<Typography.P variant="warning">Warning text</Typography.P>
<Typography.P variant="info">Info text</Typography.P>
<Typography.P variant="success">Success text</Typography.P>
<Typography.H3 variant="gradient">Gradient Heading</Typography.H3>
<Typography.P ellipsis>Long text that will be truncated with an ellipsis when it overflows the container.</Typography.P>
<Typography.P font="primary">Primary font family</Typography.P>
<Typography.P font="secondary">Secondary font family</Typography.P>Anatomy
<Typography.H1 variant="primary" ariaLabel="Page title">
Heading Text
</Typography.H1>
<Typography.P variant="secondary" ellipsis lang="en">
Paragraph content
</Typography.P>
<Typography.Label htmlFor="input-id" variant="primary">
Label text
</Typography.Label>
<Typography.Link href="/path" ariaDescribedby="link-desc">
Link text
</Typography.Link>
<Typography.Link href="https://example.com" target="_blank">
External Link
</Typography.Link>
<Typography.Code codeLang="typescript" variant="primary">
const x: string = "hello";
</Typography.Code>
<Typography.CTA variant="primary" className="text-brand">
Call to action text
</Typography.CTA>Accessibility
- Keyboard support — Links are natively focusable via
Tab;EnterorSpaceactivates them - ARIA attributes — Full support for
ariaLabel,ariaDescribedby,ariaHidden, androleprops on all components - Focus indicators — Links and Code elements display visible focus rings (
focus:ring-2) for keyboard navigation - Semantic HTML — Headings use
<h1>–<h6>, paragraphs use<p>, labels use<label>, code uses<code>, links use<a>or Next.js<Link> - Contrast compliance — All color variants use design tokens that meet WCAG 2.2 AA contrast ratios (4.5:1 for normal text, 3:1 for large text)
- External link announcements — External links append "(opens in a new tab)" or "(external link)" to
aria-labelper WCAG 2.4.4 and 2.5.3 - Touch targets — Links enforce a minimum 44px touch target (
min-h-11 min-w-11) per WCAG 2.5.8 - Language support —
langattribute for content language declaration;codeLangsetsdata-code-langand auto-generatesaria-labelon Code - Next.js Link — Internal links use Next.js
<Link>for client-side navigation with proper accessibility
Screen reader behavior
- Headings — Announced as heading level 1 through 6 based on the component used (e.g., "Heading level 1: Main Heading")
- Paragraphs — Announced as normal text content;
ariaLabeloverrides the visible text if provided - Labels — Announced as label; associated with form controls via
htmlFor - Links — Internal links announced as link text. External links announced as "Link text (external link)" or "Link text (opens in a new tab)" depending on
target - Code — Announced with role "code"; when
codeLangis set, announced as "typescript code: const x: string = hello" (or the relevant language) - CTA — Announced as paragraph text; use
roleorariaLabelfor custom semantic meaning ariaHidden— When set, the element and its content are skipped entirely by screen readers- Gradient variant — Text is visually rendered via a gradient background, but screen readers read the text content normally
Component Folder Structure
Typography/
├── index.ts # Public exports
├── Typography.tsx # Compound component assembly
├── TypographyHeadings.tsx # H1–H6 heading components
├── TypographyTextElements.tsx # P, Label, CTA components
├── TypographyLink.tsx # Link with Next.js integration
├── TypographyCode.tsx # Inline code component
├── types.ts # TypeScript type definitions
├── utils.ts # Variant class mapping utility
└── README.mdProps
Base Props
All typography components accept these props.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | Content to render. |
variant | 'primary' | 'secondary' | 'tertiary' | 'error' | 'warning' | 'info' | 'success' | 'gradient' | 'primary' | Color style variant. |
ellipsis | boolean | false | Truncate text with ellipsis on overflow. |
font | 'primary' | 'secondary' | — | Font family override. |
className | string | "" | Additional CSS classes. |
id | string | — | HTML id attribute. |
lang | string | — | Content language declaration. |
role | AriaRole | — | ARIA role override. |
ariaLabel | string | — | Accessible label. |
ariaDescribedby | string | — | ARIA describedby reference. |
ariaHidden | boolean | — | Hide element from screen readers. |
Typography.H1–H6
Each heading extends base props plus native HTMLAttributes<HTMLHeadingElement>.
| Component | Default Size | Weight |
|---|---|---|
Typography.H1 | text-4xl / sm:text-5xl / lg:text-6xl | font-bold |
Typography.H2 | text-3xl / sm:text-4xl / lg:text-5xl | font-extrabold |
Typography.H3 | text-2xl / sm:text-3xl / lg:text-4xl | font-semibold |
Typography.H4 | text-xl / sm:text-2xl / lg:text-3xl | font-semibold |
Typography.H5 | text-lg / sm:text-xl / lg:text-2xl | font-semibold |
Typography.H6 | text-base / sm:text-lg / lg:text-xl | font-semibold |
Typography.P
Extends base props plus HTMLAttributes<HTMLParagraphElement>.
| Prop | Type | Default | Description |
|---|---|---|---|
font | 'primary' | 'secondary' | 'secondary' | Font family. Defaults to secondary for body text. |
Typography.Label
Extends base props plus HTMLAttributes<HTMLLabelElement>.
| Prop | Type | Default | Description |
|---|---|---|---|
htmlFor | string | — | Associates the label with a form control. |
Typography.CTA
Extends base props plus HTMLAttributes<HTMLParagraphElement>. No additional props beyond base.
Typography.Link
Extends base props plus AnchorHTMLAttributes<HTMLAnchorElement>.
| Prop | Type | Default | Description |
|---|---|---|---|
href | string | — | URL or path. Internal paths use Next.js Link. |
target | string | — | Link target (e.g., _blank). Adds rel="noopener noreferrer" automatically. |
Typography.Code
Extends base props plus HTMLAttributes<HTMLElement>.
| Prop | Type | Default | Description |
|---|---|---|---|
codeLang | string | — | Programming language. Sets data-code-lang and auto-generates aria-label. |
role | AriaRole | "code" | ARIA role. Defaults to "code". |