VayuUI

Typography

Text styles for headings, paragraphs, links, and inline code with Accessible contrast compliance.

Installation

npx vayu-ui-cli@latest add typography

Usage

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 Components

External 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

Size Override with unsized

With unsized — stays small on all breakpoints:

Custom-sized heading

Without unsized — className only overrides the base breakpoint:

Broken override (balloons on sm/lg)

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; Enter or Space activates them
  • ARIA attributes — Full support for ariaLabel, ariaDescribedby, ariaHidden, and role props 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 Accessible 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-label per 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 — lang attribute for content language declaration; codeLang sets data-code-lang and auto-generates aria-label on 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; ariaLabel overrides 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 codeLang is set, announced as "typescript code: const x: string = hello" (or the relevant language)
  • CTA — Announced as paragraph text; use role or ariaLabel for 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.md

Props

Base Props

All typography components accept these props.

PropTypeDefaultDescription
childrenReactNode—Content to render.
variant'primary' | 'secondary' | 'tertiary' | 'error' | 'warning' | 'info' | 'success' | 'gradient''primary'Color style variant.
ellipsisbooleanfalseTruncate text with ellipsis on overflow.
font'primary' | 'secondary'—Font family override.
classNamestring""Additional CSS classes.
idstring—HTML id attribute.
langstring—Content language declaration.
roleAriaRole—ARIA role override.
ariaLabelstring—Accessible label.
unsizedbooleanfalseSkip the default size token so className fully controls sizing.
ariaDescribedbystring—ARIA describedby reference.
ariaHiddenboolean—Hide element from screen readers.

Typography.H1–H6

Each heading extends base props plus native HTMLAttributes<HTMLHeadingElement>.

ComponentDefault SizeWeight
Typography.H1text-4xl / sm:text-5xl / lg:text-6xlfont-bold
Typography.H2text-3xl / sm:text-4xl / lg:text-5xlfont-extrabold
Typography.H3text-2xl / sm:text-3xl / lg:text-4xlfont-semibold
Typography.H4text-xl / sm:text-2xl / lg:text-3xlfont-semibold
Typography.H5text-lg / sm:text-xl / lg:text-2xlfont-semibold
Typography.H6text-base / sm:text-lg / lg:text-xlfont-semibold

Overriding Heading Sizes

Headings use the application scale (text-h1 through text-h6), without breakpoint-specific size overrides. Use unsized when supplying a custom size for an intentional marketing headline. Keep application page and panel titles on the default scale.

Use the unsized prop to opt out of the default sizing block entirely:

{
  /* Stays text-sm on all breakpoints */
}
<Typography.H3 unsized className="text-sm font-semibold">
  Small heading everywhere
</Typography.H3>;

{
  /* Without unsized: balloons back to 2xl/3xl/4xl — don't do this */
}
<Typography.H3 className="text-sm">Broken override</Typography.H3>;

Typography.P

Extends base props plus HTMLAttributes<HTMLParagraphElement>.

PropTypeDefaultDescription
font'primary' | 'secondary''secondary'Font family. Defaults to secondary for body text.

Typography.Label

Extends base props plus HTMLAttributes<HTMLLabelElement>.

PropTypeDefaultDescription
htmlForstring—Associates the label with a form control.

Typography.CTA

Extends base props plus HTMLAttributes<HTMLParagraphElement>. No additional props beyond base.

Extends base props plus AnchorHTMLAttributes<HTMLAnchorElement>.

PropTypeDefaultDescription
hrefstring—URL or path. Internal paths use Next.js Link.
targetstring—Link target (e.g., _blank). Adds rel="noopener noreferrer" automatically.

Typography.Code

Extends base props plus HTMLAttributes<HTMLElement>.

PropTypeDefaultDescription
codeLangstring—Programming language. Sets data-code-lang and auto-generates aria-label.
roleAriaRole"code"ARIA role. Defaults to "code".

Application heading scale

Headings use the semantic text-h1–text-h6 tokens, approximately 30/24/20/18/16/14px at the default base size. They keep that scale across breakpoints instead of automatically expanding to hero sizes. Choose heading levels for document structure; use shared tokens to change the product-wide scale.

Reserve unsized and large display classes for an intentional marketing design. Card and overlay titles usually need 16–20px. Typography.Link uses native anchors in every React framework; use your router's link component when client-side routing is required.

On this page