Ir al contenido
Español

Cómo funciona

A 24px-high pill (20px in size sm) with 13px / 500 text and a 6px dot in the pure status colour. Five semantics (success, warning, danger, progress, neutral) use a soft background and a text colour mixed 62% status colour with body text, which keeps at least 4.5:1 on cards and light grey panels in both themes. When status changes, the tint and text colour cross-fade in 240ms and the new dot (or icon) pops in with a slight overshoot; nothing moves on first render, so a long list does not flicker on load. With icon, shape tells states apart for colour-blind users. It is only text: not clickable, not in the Tab order. The demo is a launch task list whose tasks move on by themselves.

Úsalo para

  • Showing a record's state in lists, tables and detail pages: tasks, orders, payouts.
  • Several states side by side on a page, to tell done, watch, failing, running and ended apart at a glance.
  • States that screen readers and colour-blind users must also be able to read: text is always present.

Busca otra opción cuando

  • Anything that should filter, close or navigate on click: use a button, a link or a selectable chip.
  • Counts or unread markers: use a numeric badge.
  • Categories such as genre or campaign names: a category is not a state, so do not use the five status colours.

Uso

import { StatusTag } from './StatusTag.jsx'

// Map your own states to the 5 semantics, so one meaning always has one colour
const TASK_STATE = {
  running: { status: 'progress', text: 'In progress' },
  done: { status: 'success', text: 'Done' },
  overdue: { status: 'danger', text: 'Overdue' },
  pending: { status: 'warning', text: 'Pending' },
  cancelled: { status: 'neutral', text: 'Cancelled' },
}

export function TaskStateTag({ state }) {
  const { status, text } = TASK_STATE[state]
  // Only states that are still running pulse
  return (
    <StatusTag status={status} pulse={state === 'running'}>
      {text}
    </StatusTag>
  )
}

Propiedades

PropiedadTipoPor defectoQué hace
status'success' | 'warning' | 'danger' | 'progress' | 'neutral''neutral'Semantic: sets the background, text and dot colour.
childrenReactNode—The label text. Required: state must not rely on colour alone.
iconReactNode—Replaces the dot with a 14px icon (12px in sm; pass an svg, it takes the status colour). The dot is then hidden.
pulsebooleanfalseGives the dot a pulsing halo to show something is still running. Static under reduced motion; no effect with an icon.
size'md' | 'sm''md'md is 24px high with 13px text; sm is 20px with 12px text for dense tables.
classNamestring—Class name added to the root <span>.
...restHTMLAttributes—Other attributes (title, data-*, aria-*) go to the root <span>.

Accesibilidad

  • A plain <span>: not clickable, not in the Tab order; screen readers read the label text.
  • State is not colour alone: text is required and the dot or icon is decorative (aria-hidden).
  • The text colour keeps at least 4.5:1 on cards, page backgrounds and light grey rows.
  • The pulse halo and the change pop move only transform and opacity and are off under reduced motion.
  • In forced-colors (high contrast) mode the background is dropped, a thin outline is added and the dot uses the system text colour.

Movimiento

Still on first render. On a status change: colours cross-fade in 240ms and the dot pops from 0.2× to 1× in 360ms with a spring curve. With pulse, a halo behind the dot grows to 2.6× and fades every 1.6s, ease-out.

Añádelo a tu proyecto

Copia la instrucción en Codex o Claude Code. El agente lee el código publicado, te muestra lo que va a escribir y añade el componente junto a los tuyos.

StatusTag.jsxstatus-tag.csstokens.cssREADME.md

Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.

Datos
Diferencias de código viene con Pro. La vista previa aparece al desbloquearlo.
Cuenta atrás con flip viene con Pro. La vista previa aparece al desbloquearlo.