Text

Slant / Primitives

Title, body, hint, label and monospace text on the theme's type scale, as any element.

Demo

Usage

@tuttn/slant
import { Text } from '@tuttn/slant'

<Text variant="title" as="h2">Checkpoints</Text>   // a heading needs as
<Text>Saved every five minutes.</Text>              // body, a <p>
<Text muted>Last saved 2m ago.</Text>
<Text variant="hint">Applies to every branch.</Text>
<Text variant="mono">TASK-24</Text>                 // label and mono are spans

// as picks the element; htmlFor and dateTime go with label and time.
<Text as="label" variant="label" htmlFor="branch">Branch</Text>
<Text as="time" variant="mono" dateTime="2026-10-30T09:12">09:12</Text>

Props

PropTypeDefaultDescription
variant'body' | 'title' | 'hint' | 'label' | 'mono''body'body: 13px copy · title: a 14px semibold heading · hint: 12px muted · label: uppercase mono · mono: 12px mono
mutedboolean—The secondary text colour.
as'p' | 'span' | 'div' | 'h2' | 'h3' | 'h4' | 'strong' | 'label' | 'time' | 'dt' | 'dd' | 'legend' | 'caption''span' for label and mono, else 'p'The element to render.
htmlForstring—The control a label names, with as="label".
dateTimestring—The machine-readable date, with as="time".
…restHTMLAttributes—className, style, id and every other attribute go on the element, and a ref reaches it.

Accessibility

  • variant changes only the look; as picks the element. A title is a <p> until you pass as="h2" (or h3, h4), and only then is it a heading screen readers can jump to.
  • The label variant is a <span>. To name a control, make it a real label: as="label" with htmlFor.
  • Muted and hint text hold 4.5:1 against the theme's background and surfaces in every theme.