Text

Type styles for headings, body and inline text.

Source
$npx @dinachi/cli@latest add text

The quick brown fox

variant
as
children

Usage

import { Text } from "@/components/ui/text"

export function Intro() {
  return (
    <div>
      <Text variant="h2">Release notes</Text>
      <Text variant="muted">Updated every Tuesday.</Text>
    </div>
  )
}

Examples

Heading 1

Heading 2

Heading 3

Heading 4

Paragraph — the default variant with comfortable line height.

Large text for emphasized body content.

Small text for captions and metadata.

Lead text for introductory paragraphs.

Muted text for secondary information and descriptions.

The best way to predict the future is to invent it.
console.log("hello world")Inline span text for use within other elements.
Every type style, from headings to muted text.
import { Text } from '@/components/ui/text';

export function Example() {
  return (
    <div className="space-y-4">
      <Text variant="h1">Heading 1</Text>
      <Text variant="h2">Heading 2</Text>
      <Text variant="h3">Heading 3</Text>
      <Text variant="h4">Heading 4</Text>
      <Text variant="p">Paragraph — the default variant with comfortable line height.</Text>
      <Text variant="large">Large text for emphasized body content.</Text>
      <Text variant="small">Small text for captions and metadata.</Text>
      <Text variant="lead">Lead text for introductory paragraphs.</Text>
      <Text variant="muted">Muted text for secondary information and descriptions.</Text>
      <Text variant="blockquote">The best way to predict the future is to invent it.</Text>
      <Text variant="code">console.log("hello world")</Text>
      <Text variant="span">Inline span text for use within other elements.</Text>
    </div>
  );
}

Notes

Rendered elements

  • h1 to h4: their heading.
  • blockquote, code: that element.
  • span: an unstyled <span>.
  • p, large, small, lead, muted: a <p>. Use as="span" inside another paragraph.

Heading level

Set the level from the outline and the variant from the design: <Text variant="h2" as="h3">.

textVariants

Also exported. Call it to style your own element, such as a link or label.

API

variant"h1" | "h2" | "h3" | "h4" | "p" | "large" | "small" | "lead" | "muted" | "blockquote" | "code" | "span" = "p"
The type style. Also picks the element unless as is set.
asElementType
Renders another element with the same style, such as an h2 look on an h3.
childrenReactNode
The text.

Accessibility

  • Each variant renders a semantic element; headings join the outline.
  • Keep heading levels in order; use as when design and outline disagree.