Components / Layout and type
Text
Text in one of the type styles from tokens.json. Picks a matching element (h1, p, code…) unless you pass as.
import { Text } from "@stylhero/ui";
Example
Code
import { Stack, Text } from "@stylhero/ui";
function TextExample() {
return (
<Stack gap={2}>
<Text variant="h2">Heading 2</Text>
<Text variant="lead">A lead paragraph, a little larger.</Text>
<Text>Body text.</Text>
<Text variant="small" tone="muted">Small, muted text.</Text>
<Text variant="mono">npm i @stylhero/ui</Text>
</Stack>
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
as |
ElementType |
- | Override the HTML tag, e.g. variant="h1" as="h2" for an h1 look at h2 level. |
tone |
"ink" | "muted" | "primary" | "success" | "danger" |
- | |
variant |
Variant |
"body" |
Type style from tokens.json. |
Also takes the HTML attributes of its root element (id, style, data-*, aria-*, event handlers…).
Types
type Variant = "display" | "h1" | "h2" | "h3" | "lead" | "body" | "small" | "label" | "mono" | "strong";
Generated from src/components/Text.tsx. Something wrong or missing? Open an issue.