Badge
Slant / Primitives
Small labels in every tone, with an optional pixel and a monospace variant for numbers.
Demo
Usage
import { Badge } from '@tuttn/slant'
<Badge>Draft</Badge> // neutral: muted text in a hairline box
<Badge tone="success">Shipped</Badge>
<Badge tone="accent" pixel>New</Badge> // accent also tints the background
// mono: 11px monospace, for numbers, deltas and versions.
<Badge mono tone="success">+12.4%</Badge>
<Badge mono>v0.4.0</Badge>Props
| Prop | Type | Default | Description |
|---|---|---|---|
tone | Tone | 'neutral' | Text colour; `accent` also tints the background. |
pixel | boolean | — | Leads with a slanted pixel in the badge's colour. |
mono | boolean | — | Monospace at 11px, for numbers and deltas. |
…rest | HTMLAttributes | — | className, style, aria-* and every other attribute go on the <span>, and a ref reaches it. |
Accessibility
- A badge is a
<span>with no role: screen readers read its text in line with the content around it. - The tone is colour only. Put the meaning in the words ("Failed", not a red "!"), so the badge reads the same without colour.
- The
pixelis decorative (aria-hidden). - Every tone holds 4.5:1 against the theme's background and surfaces, and accent against its own tint, in every theme.
Badge or Chip? A badge is a static label: a version, a count, a status word. A Chip shows a live state with a moving indicator, and becomes a button when you give it an onClick.