Pill
A compact static label for statuses, categories, method tags, and counts with animated swaps and spring width morphing.
import { Pill } from '@uthereal/ui/pill'Pill playground
Overview
Pill renders a compact inline label for a status (Active), category (Design), HTTP method (GET), or count (12 new). Keep the same instance mounted and update label, children, icon, or tone to animate the transition in place: the new text rises through a soft blur while the container springs to its new width.
Pill is static text, not an interactive control. Use Button for actions or toggles, TagInput for editable tag lists, and ShortcutInput for recording keyboard shortcuts.
Usage
'use client'
import { Pill } from '@uthereal/ui/pill'
type DeployState = 'queued' | 'deploying' | 'live' | 'failed'
const states: Record<
DeployState,
{
label: string
tone: 'neutral' | 'info' | 'success' | 'danger'
icon: 'clock' | 'sparkles' | 'check' | 'triangle-alert'
}
> = {
queued: { label: 'Queued', tone: 'neutral', icon: 'clock' },
deploying: { label: 'Deploying', tone: 'info', icon: 'sparkles' },
live: { label: 'Live', tone: 'success', icon: 'check' },
failed: { label: 'Failed', tone: 'danger', icon: 'triangle-alert' },
}
export function DeployStatus({ state }: { state: DeployState }) {
const current = states[state]
return <Pill label={current.label} tone={current.tone} icon={current.icon} />
}In React, string or number children replace label and participate in the same text swap and width morph. Richer JSX children render directly inside the pill.
Examples
Use <SchemaPlayground /> above to inspect individual props, recipe, theme, and motion presets. The sets below show semantic tones, categorical colors, and structural decorations.
Semantic tones
tone selects a semantic status role. Pair status tones (success, info, warning, danger) with words that state the same status so meaning never relies on color alone.
Categorical colors
color selects from the shared six-hue categorical palette (teal, sky, orchid, violet, rose, amber) and overrides tone. Use categorical colors for non-status taxonomies such as HTTP methods or labels.
Sizes, marks, outline, and corners
size scales the pill on a 4 px grid (sm, md, lg). Add dot for live statuses or icon for a leading glyph (when both are set, icon takes precedence and dot is ignored). Set outline to draw a hairline border on busy surfaces, and set rounded="default" to use soft corners instead of full pill ends.
Tones, colors, and sizes
All tints mix in oklab against --ui-surface, --ui-text, and --ui-border so every hue adapts across light mode, dark mode, and both studio and soft recipes.
| Prop | Value | Role | Base token | Notes |
|---|---|---|---|---|
tone | neutral | Categories, counts, metadata | --ui-text-secondary | Default role; does not follow accent |
tone | success | Completed, healthy, active state | --ui-success | Pair with explicit status wording |
tone | info | Informational or in-progress note | --ui-info | Semantic info hue |
tone | warning | Caution, pending review, limits | --ui-warning | Light mode deepens text mix to 76% for AA ink |
tone | danger | Failure, error, destructive flag | --ui-danger | Doubles outline under forced-colors: active |
color | teal | Categorical tag (e.g. GET) | --ui-pill-teal | Light #007467 / Dark #37d5c1; overrides tone |
color | sky | Categorical tag (e.g. POST) | --ui-pill-sky | Light #136d9e / Dark #7cc4f0; overrides tone |
color | orchid | Categorical tag (e.g. PUT) | --ui-pill-orchid | Light #943fa2 / Dark #dd8fe9; overrides tone |
color | violet | Categorical tag (e.g. PATCH) | --ui-pill-violet | Light #6850b9 / Dark #aa9df4; overrides tone |
color | rose | Categorical tag (e.g. DELETE) | --ui-pill-rose | Light #bb2c54 / Dark #f0738f; overrides tone |
color | amber | Categorical tag (e.g. HEAD) | --ui-pill-amber | Light #9f6202 (76% ink) / Dark #f2bd68 |
size | Height | Default radius (rounded="default") | Inline padding | Mark-to-label gap | Text size | Icon size | Dot size |
|---|---|---|---|---|---|---|---|
sm | 20 px | 5 px | 8 px | 4 px | 11 px | 12 px | 5 px |
md | 24 px | 6 px | 10 px | 5 px | 12 px | 14 px | 6 px |
lg | 28 px | 7 px | 12 px | 6 px | 14 px | 16 px | 7 px |
When a leading mark is present, padding-inline-start tightens by 2 px for icon and 1 px for dot so visual balance matches the trailing edge in both LTR and RTL layouts.
API reference
Serializable schema arguments and defaults come directly from pillConfigSchema.
| Argument | Type / default | Description |
|---|---|---|
label | stringDefault: "Pill" | Visible text, kept short: a status ("Active"), a category ("Design") or a count ("12 new"). Keep the pill mounted and change the label for the morph; remounting with a new key loses it. |
tone | neutral | success | info | warning | dangerDefault: "neutral" | Color role. neutral is secondary text; success, warning, danger and info report a state — use them only when the label states that status, and pair the words with the color. |
color | teal | sky | orchid | violet | rose | amber— | Categorical color from the shared tone family (Arc's --tone-* palette), for labels such as method tags: GET teal, POST sky, PUT orchid, PATCH violet, DELETE rose. Overrides tone; never use a categorical color to mean success or failure. |
size | sm | md | lgDefault: "md" | Height: 20, 24 or 28 pixels with 11, 12 or 14 pixel text, as in Arc. |
icon | IconName— | Decorative icon before the label, from the Icons page, in the tone color. Takes precedence over dot. |
dot | booleanDefault: false | A small dot in the tone color before the label, for live statuses. Ignored when an icon is set. |
outline | booleanDefault: false | Draw a hairline border in the tone color. |
rounded | default | fullDefault: "full" | default keeps the size's soft corners (5, 6 or 7 px); full is the original pill-shaped ends. |
recipe | studio | softDefault: "studio" | Visual treatment. Both recipes behave the same way. |
theme | PillTheme— | Color mode, and tokens for colors, type, the height, radius, padding, gap, text, icon and dot sizes, and the categorical tone colors. See Theming. |
motion | none | subtle | expressiveDefault: "subtle" | Label and icon swaps (the new text rises through a small blur while the pill springs to its new width) and tone color transitions. System reduced-motion preferences fade instead and snap the width. |
motionOptions | PillMotionOptions— | Label swap duration and the width transition. |
dir | ltr | rtl— | Reading direction. Omit it to inherit the page direction. |
React integration
| Prop | Purpose |
|---|---|
children | String or number replaces label with full swap/morph motion; richer React nodes render directly. |
renderIcon(name, context) | Replaces the decorative leading icon (context provides { size, slot: 'icon' }); wrapped in IconSlot. |
preset | Application defaults overridden by explicit instance props (label and icon are excluded). |
tokens | --ui-* CSS variables applied after the typed theme. |
ref | Ref to the root <span> element. |
className, style | Forwarded to the root <span>; style wins over motion and theme tokens. |
Native <span> attributes | id, title, role, aria-*, data-*, and event handlers forwarded to the root <span>. |
Accessibility
Pill renders a non-focusable <span> with no interactive keyboard stops. During animated label or icon swaps, outgoing exiting copies receive aria-hidden="true" so screen readers announce only the active text. Leading dot and icon marks are decorative (aria-hidden="true").
All layout rules use CSS logical properties (min-inline-size, padding-inline-start, inline-size, block-size) and honor dir="rtl" (or inherited page direction when dir is omitted). Under forced-colors: active, every pill draws a CanvasText border, tone="danger" adds a 2 px inset CanvasText outline, and the status dot uses CanvasText with forced-color-adjust: none.
Motion and theming
Pill animates content changes in place while keeping passive layout reflows (such as webfont loading or container visibility toggles) instant: ResizeObserver springs the inline width only within a 120 ms window after label, children, icon, or dot changes.
| Mode | Label swap | Icon swap | Width change | Color transition |
|---|---|---|---|---|
motion="subtle" (default) | Rise 0.3em, 4 px → 0 px blur, 240 ms / 160 ms | Scale 0.6 → 1, snappy spring | Morph spring (0.42s, 0.16) | 240 ms (standard ease) |
motion="expressive" | Rise 0.3em, 8 px → 0 px blur, 240 ms / 160 ms | Scale 0.6 → 1, snappy spring | Morph spring (0.42s, 0.16) | 240 ms (standard ease) |
prefers-reduced-motion: reduce | Opacity crossfade, 120 ms | Opacity crossfade, 120 ms | Snaps immediately | 120 ms |
motion="none" | Immediate (0 ms) | Immediate (0 ms) | Snaps immediately | Immediate (0 ms) |
Tune swap timing with motionOptions.labelDuration (milliseconds) and motionOptions.width (spring or tween transition).
| Token group | CSS custom properties |
|---|---|
| Global theme | --ui-surface, --ui-text, --ui-text-secondary, --ui-border, --ui-border-width, --ui-info, --ui-success, --ui-warning, --ui-danger, --ui-font, --ui-font-weight |
| Pill scale | --ui-pill-height, --ui-pill-radius, --ui-pill-pad, --ui-pill-gap, --ui-pill-text-size, --ui-pill-icon-size, --ui-pill-dot-size |
| Pill colors | --ui-pill-teal, --ui-pill-sky, --ui-pill-orchid, --ui-pill-violet, --ui-pill-rose, --ui-pill-amber |
UtherealProvider supplies application-wide recipe, theme, and motion defaults below preset and instance props.
Composition
In agent compositions, Pill is a leaf with no actions or persisted state.
{
"type": "Pill",
"props": {
"label": "POST",
"color": "sky",
"size": "sm",
"outline": true,
"rounded": "default"
},
"children": []
}