Text
A passive typography primitive with standardized size, tone, weight, font, leading, and tracking props.
A passive text container that standardizes typographic props—size, tone, weight, font family, line height, tracking, emphasis, and decoration—while styled components provide the visual typography scale.
Preview
Section titled “Preview” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases (CLI target: base-text). Import textRoot (along with asTextRoot, TextRootProps, and TextRootExposes) from @proto.ui/prototypes-base/text or the package root.
import * as React from 'react';import { createReactAdapter } from '@proto.ui/adapter-react';import { textRoot } from '@proto.ui/prototypes-base/text';
const Text = createReactAdapter(React)(textRoot, { rootTag: 'span' });
export function SectionTitle() { return ( <h1> <Text size="4xl" font="heading" weight="semibold" leading="tight" tracking="tight"> Account settings </Text> </h1> );}Semantic wrappers and typography rules
Section titled “Semantic wrappers and typography rules”- Keep native document semantics:
rootTag: 'span'is a Web Adapter option. Keep headings (<h1>), paragraphs (<p>), labels (<label htmlFor>), and links (<a href>) on native host elements;Textadds no focus stop or activation handler. - Foreground inheritance: Set
tone="inherit"on styledTextinsidesolidoraccentSurfacecontainers so it inherits the enclosing foreground color. - Size and line height: Removing a prop restores its default. An initially invalid
sizefalls back to'base', while an invalid update after a valid value retains the previous value.leading="size"keeps the size’s built-in line box (in Shadcn and Brutalist,xsthrough5xlmap to1rem,1.25rem,1.5rem,1.75rem,1.75rem,2rem,2.25rem,2.5rem, and1);leading="tighter"selects1.1andtracking="tighter"selects-0.05em.
| Prop | Type | Default |
|---|---|---|
size | 'xs' 'sm' 'base' 'lg' 'xl' '2xl' '3xl' '4xl' '5xl' | base |
tone | 'default' 'muted' 'inherit' | default |
weight | 'normal' 'medium' 'semibold' 'bold' | normal |
font | 'body' 'heading' 'mono' | body |
leading | 'size' 'tighter' 'tight' 'snug' 'normal' 'relaxed' | normal |
tracking | 'normal' 'tight' 'tighter' | normal |
emphasis | 'normal' 'italic' | normal |
decoration | 'none' 'underline' 'line-through' | none |
Exposes no extra state, methods, or events and renders your children in the default slot.