Text
Body copy in the theme type scale, with tones, weights, mono and truncation.
Status: stable. Category: Typography.
import { Text } from '@glyphui/ui'
Exports: Text, textStyles.
Text props
| Prop | Type | Default | Description |
|---|---|---|---|
asChild | boolean | Render the child element (e.g. <span>, <label>) with text styles instead of a <p>. | |
mono | boolean | ||
size | "body" | "caption" | "small" | "lead" | ||
tone | "default" | "primary" | "success" | "warning" | "danger" | "muted" | "faint" | ||
truncate | boolean | ||
weight | "regular" | "medium" | "semibold" |
Example: Sizes
import { Text } from '@glyphui/ui'
export default function Example() {
return (
<div className="grid max-w-xl gap-3">
<Text size="lead">A lead paragraph introduces a page in one or two calm sentences.</Text>
<Text>Body text is tuned for long reading, with comfortable line height.</Text>
<Text size="small">Small text for helper copy, metadata and table cells.</Text>
<Text size="caption" mono>
CAPTION · $48,210.00 · 12.4%
</Text>
</div>
)
}
Example: Tones
import { Text } from '@glyphui/ui'
export default function Example() {
return (
<div className="grid gap-1">
<Text>Default foreground</Text>
<Text tone="muted">Muted, for secondary text</Text>
<Text tone="faint">Faint, for hints and placeholders</Text>
<Text tone="primary" weight="medium">
Primary
</Text>
<Text tone="success">Payment received</Text>
<Text tone="danger">Card declined</Text>
</div>
)
}
Example: Other elements
Renders a <p> by default; asChild styles a span, label or anything else.
import { Text } from '@glyphui/ui'
export default function Example() {
return (
<p className="text-body">
Signed in as{' '}
<Text asChild weight="semibold">
<span>[email protected]</span>
</Text>
.
</p>
)
}
Live page: https://glyphui.xyz/components/text