本文へ移動
日本語

仕組み

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.

向いている場面

  • 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.

向かない場面

  • 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.

使い方

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>
  )
}

プロパティ

プロパティ型既定値説明
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>.

アクセシビリティ

  • 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.

モーション

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.

プロジェクトに追加

プロンプトを Codex または Claude Code に貼り付けます。エージェントが公開ソースを読み、書き込む内容を示したうえで、既存のコンポーネントの隣に追加します。

StatusTag.jsxstatus-tag.csstokens.cssREADME.md

2 つのファイルを一緒に導入します。スタイルは tokens.css の変数を読み、予備の値も持つため、単体でも表示できます。

データ表示
「コード差分」は Pro に含まれます。解除するとプレビューが表示されます。
「フリップカウントダウン」は Pro に含まれます。解除するとプレビューが表示されます。