Ir al contenido
Español

Cómo funciona

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.

Úsalo para

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

Busca otra opción cuando

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

Uso

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

Propiedades

PropiedadTipoPor defectoQué hace
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.

Accesibilidad

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

Movimiento

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.

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.

ChipGroup.jsxchip-group.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.

Formularios
Cuadrícula de disponibilidad viene con Pro. La vista previa aparece al desbloquearlo.
Operaciones booleanas viene con Pro. La vista previa aparece al desbloquearlo.
Selector en cascada viene con Pro. La vista previa aparece al desbloquearlo.