Skip to content

Router that virtually distributes inference across connected devices in the home.

Go
19.9 KB
Raw Blame

Text

A primitive component for displaying text.

Examples

Kinds Text

Pick a kind from one of the five families: display/* for the largest hero text, title/* for headings, body/* for prose, label/* for short UI labels, and mono/* for code or technical identifiers. Each family offers multiple sizes and weights — see the kind type for the full set.

<Stack gap="density-md">
    <Text kind="display/lg">Display Heading</Text>
    <Text kind="title/md">Section Title</Text>
    <Text kind="body/regular/md">The quick brown fox jumps over the lazy dog</Text>
    <Text kind="label/semibold/sm">Form Label</Text>
    <Text kind="mono/md">console.log("hello")</Text>
</Stack>

Custom Styled Text

Reach for the granular fontFamily, fontWeight, fontSize, lineHeight, and fontStyle props as an escape hatch when no predefined kind matches the design.

<Text fontFamily="sans" fontWeight="semibold" fontSize="18" lineHeight="150" fontStyle="italic">
    Custom typography
</Text>

Underlined Text

Add the underline prop on top of any kind to flag inline emphasis like links or highlighted terms without changing the type style.

<Text kind="body/regular/md" underline>
    Underlined passage
</Text>

Inherit Kind Text

Use kind="inherit" when Text is nested inside an element that already defines the type style (e.g. inside another Text or a styled heading) and you only need the Text primitive's other props.

<Text kind="inherit">Inherits parent typography</Text>

As Child Text

Use asChild to apply Text styling to a semantic HTML element like h1–h6 without adding an extra wrapper.

<Text asChild kind="title/lg">
    <h1>Semantic Heading</h1>
</Text>

Props

Prop Type Default Description
asChild boolean - When true, renders the immediate child instead of the default element, merging this component's props with the child's props.
fontFamily "sans" | "mono" - The font family of the text.
fontSize "10" | "12" | "14" | "16" | "18" | "20" | "22" | "24" | "28" | "32" | "36" | "40" | "44" | "48" | "50" | "56" | "60" | "64" | "72" | "80" - The font size of the text.
fontStyle "normal" | "italic" - The font style of the text.
fontWeight "bold" | "light" | "regular" | "semibold" - The font weight of the text.
kind "inherit" | "body/bold/2xl" | "body/bold/3xl" | "body/bold/lg" | "body/bold/md" | "body/bold/xl" | "body/bold/sm" | "body/bold/xs" | "body/regular/lg" | "body/regular/md" | "body/regular/sm" | "body/regular/xl" | "body/regular/2xl" | "body/regular/3xl" | "body/regular/xs" | "body/semibold/2xl" | "body/semibold/3xl" | "body/semibold/lg" | "body/semibold/md" | "body/semibold/sm" | "body/semibold/xl" | "body/semibold/xs" | "display/2xl" | "display/xl" | "display/lg" | "display/md" | "display/sm" | "display/xs" | "label/bold/2xl" | "label/bold/3xl" | "label/bold/lg" | "label/bold/md" | "label/bold/sm" | "label/bold/xl" | "label/bold/xs" | "label/light/lg" | "label/light/xl" | "label/light/2xl" | "label/light/3xl" | "label/light/md" | "label/light/sm" | "label/light/xs" | "label/regular/lg" | "label/regular/md" | "label/regular/sm" | "label/regular/xs" | "label/regular/xl" | "label/regular/2xl" | "label/regular/3xl" | "label/semibold/lg" | "label/semibold/md" | "label/semibold/sm" | "label/semibold/xl" | "label/semibold/2xl" | "label/semibold/3xl" | "label/semibold/xs" | "mono/md" | "mono/sm" | "mono/lg" | "mono/xl" | "mono/2xl" | "title/2xl" | "title/xl" | "title/lg" | "title/md" | "title/sm" | "title/xs" "label/regular/md" The kind of text to display. We offer a variety of groupings: - display - the largest text on the screen, use for short, important text or numerals - title - smaller than display - use for medium-emphasis text that remains relatively short - body - use for longer passages of text - label - use for short labels - mono - use for code or technical content Each of these groups has a variety of weights and sizes. If you want it to inherit the text style from its parent, you can use the inherit kind.
lineHeight "100" | "125" | "150" | "175" - The line-height of the text.
underline boolean - Whether or not the text should be underlined.