本文へ移動
日本語

仕組み

The check sits in a grid column that animates from 0fr to 1fr, so the chip grows by exactly the check's width and neighbours glide aside. The stroke draws over 240ms after the column opens. The active chip uses the ink colour rather than the accent, which keeps a dense filter bar calm.

向いている場面

  • Filters above results that apply at once: amenities, price bands, categories.
  • Picking one short option from three to six where a segmented control would be too wide.

向かない場面

  • Free-form values typed by people: use a tags input.
  • Dozens of options: use a multi-select with search.

使い方

import { useState } from 'react'
import { ChipGroup } from './ChipGroup.jsx'

export function Amenities() {
  const [picked, setPicked] = useState(['wifi'])
  return (
    <ChipGroup
      label="Amenities"
      multiple
      items={[
        { value: 'wifi', label: 'Fast wifi', count: 128 },
        { value: 'kitchen', label: 'Kitchen', count: 96 },
        { value: 'desk', label: 'Desk', count: 74 },
      ]}
      value={picked}
      onChange={setPicked}
    />
  )
}

プロパティ

プロパティ型既定値説明
items{ value, label, icon?, count?, disabled? }[]—The chips. value must be unique; icon is any node drawn before the label.
multiplebooleanfalseMany chips can be on (toggle buttons); otherwise exactly one (a radio group).
valuestring | string[] | null—Controlled: the chosen value, or an array when multiple.
defaultValuestring | string[] | null—Initial value when uncontrolled.
onChange(value) => void—Called with the new value or array.
size'sm' | 'md' | 'lg''md'Chip height 32 / 36 / 44. Use lg on touch-first screens.
labelstring—Accessible name of the group; or pass aria-labelledby.
disabledbooleanfalseDisables every chip.
...restHTMLAttributes<HTMLDivElement>—Passed to the group element.

アクセシビリティ

  • multiple renders toggle buttons with aria-pressed inside role="group"; single renders role="radiogroup" with role="radio" chips and aria-checked.
  • Single choice uses a roving tab stop: Tab enters on the chosen chip, arrows and Home / End move and choose. Multiple: Tab moves between chips, Space or Enter toggles.
  • The state is carried by the fill and the check, not colour alone. Focus shows a 3px accent ring.
  • Chips are 32 / 36 / 44px high. Reduced motion keeps the colour change but drops the slide, widening and stroke drawing.

モーション

The check column opens over 320ms on a soft spring (cubic-bezier(0.32, 1.35, 0.55, 1)); its stroke draws in 240ms ease-out after an 80ms delay. Fill and colour cross-fade in 200ms. A press scales the chip to 0.96.

プロジェクトに追加

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

ChipGroup.jsxchip-group.csstokens.cssREADME.md

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

フォーム入力
「空き時間グリッド」は Pro に含まれます。解除するとプレビューが表示されます。
「図形のブール演算」は Pro に含まれます。解除するとプレビューが表示されます。
「カスケード選択」は Pro に含まれます。解除するとプレビューが表示されます。