本文へ移動
日本語

仕組み

Every variant draws from one box and scales its strokes from it, so sizes never look heavier or lighter than each other. The ring is a conic gradient masked to a band, with a round cap on the leading end and a tail that fades into a faint track; it turns on an ease-in-out curve so it feels driven rather than mechanical.

向いている場面

  • Waits of about 300ms to a few seconds where the length is unknown.
  • Inside buttons, chips and rows to show that one item is busy.

向かない場面

  • Known progress: show a progress bar or ring with a value.
  • Loading a whole layout: use skeletons that match the content.
  • Waits under 300ms: show nothing, to avoid a flash.

使い方

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

export function SaveButton({ saving }) {
  return (
    <button aria-busy={saving}>
      {saving ? <Spinner size="sm" label="Saving" /> : null}
      {saving ? 'Saving' : 'Save'}
    </button>
  )
}

プロパティ

プロパティ型既定値説明
variant'ring' | 'dots' | 'bars' | 'pulse''ring'Which mark. ring for general waits, dots for chat or inline text, bars for audio or live data, pulse for background sync.
size'xs' | 'sm' | 'md' | 'lg' | 'xl' | number'md'14 / 18 / 24 / 32 / 44 px, or any number of px. Strokes scale with it.
speednumber1Multiplies the speed of every variant.
labelstring'Loading'Announced text, visually hidden.
...restHTMLAttributes<HTMLSpanElement>—Passed to the root. Set color (or the parent's) to tint it.

アクセシビリティ

  • The root is role="status" with a visually hidden label, so the wait is announced once; the drawing is aria-hidden.
  • When the spinner sits in a button, also set aria-busy on the button and keep its text.
  • Reduced motion stops all rotation, travel and ripples; the mark only fades slowly in place.

モーション

Ring: one turn per 900ms on cubic-bezier(0.45, 0.15, 0.4, 0.9). Dots: 1100ms swell, staggered by 180ms. Bars: 1000ms rise, staggered by 150ms. Pulse: 1400ms breath with two ripples half a cycle apart. All divide by speed.

プロジェクトに追加

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

Spinner.jsxspinner.csstokens.cssREADME.md

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

読み込み
「画像リビール」は Pro に含まれます。解除するとプレビューが表示されます。
「オービットローダー」は Pro に含まれます。解除するとプレビューが表示されます。