$npx @dinachi/cli@latest add text
The quick brown fox
varianth1
h2
h3
h4
p
large
small
lead
muted
blockquote
code
span
asdefault
h2
p
span
label
childrenheadline.tsx
import { Text } from "@/components/ui/text"
export function Headline() {
return (
<Text variant="h2">The quick brown fox</Text>
)
}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>
);
}The quick brown fox jumps over the lazy dog. This is a default paragraph rendered as a <p> element with comfortable leading.
A plain paragraph.
import { Text } from '@/components/ui/text';
export function Example() {
return (
<Text>
The quick brown fox jumps over the lazy dog. This is a default paragraph
rendered as a {'<p>'} element with comfortable leading.
</Text>
);
}Styled as h2, rendered as <h3>
Styled as muted, rendered as <span> instead of <p>The as prop changes the element and keeps the style.
import { Text } from '@/components/ui/text';
export function Example() {
return (
<div className="space-y-4">
<Text variant="h2" as="h3">
Styled as h2, rendered as {'<h3>'}
</Text>
<Text variant="muted" as="span">
Styled as muted, rendered as {'<span>'} instead of {'<p>'}
</Text>
</div>
);
}Notes
Rendered elements
h1toh4: their heading.blockquote,code: that element.span: an unstyled<span>.p,large,small,lead,muted: a<p>. Useas="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
aswhen design and outline disagree.