How it works
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.
Use it for
- 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.
Look elsewhere when
- Free-form values typed by people: use a tags input.
- Dozens of options: use a multi-select with search.
Usage
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}
/>
)
}Props
| Prop | Type | Default | What it does |
|---|---|---|---|
items | { value, label, icon?, count?, disabled? }[] | — | The chips. value must be unique; icon is any node drawn before the label. |
multiple | boolean | false | Many chips can be on (toggle buttons); otherwise exactly one (a radio group). |
value | string | string[] | null | — | Controlled: the chosen value, or an array when multiple. |
defaultValue | string | 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. |
label | string | — | Accessible name of the group; or pass aria-labelledby. |
disabled | boolean | false | Disables every chip. |
...rest | HTMLAttributes<HTMLDivElement> | — | Passed to the group element. |
Accessibility
- 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.
Motion
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.
Add it to your project
Copy the prompt into Codex or Claude Code. The agent reads the published source, shows you what it will write and adds the component next to your own.
ChipGroup.jsxchip-group.csstokens.cssREADME.md
Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.





