Skip to content

Chip

Interactive compact element for filters, selections, and removable attributes.

  • stable
  • since v0.1.0
  • 2.5 kB
  • feedback
  • filter
  • selection

Chip renders a native <button> with aria-pressed to convey selection state. The dismiss control is a separate focusable button labelled via removeLabel (defaults to Remove {label} or Remove).

Preview
Open
tsx

Chip ships four visual variants — solid, soft (default), outline, and ghost — each available across six colour schemes (accent, neutral, success, warning, danger, info).

Preview
Open
tsx

Three sizes are available: xs, sm, and md (default).

Preview
Open
tsx

Chips support a controlled selected boolean with onSelectedChange for toggle-style filters. Selection state is mirrored to aria-pressed.

Preview
Open
tsx

Pass onRemove to render a dismiss control next to the chip label. The chip splits into two focusable buttons — the label and the remove control — so each is independently keyboard reachable.

Preview
Open
tsx

Use leftIcon or rightIcon to decorate the chip with a leading or trailing glyph.

Preview
Open
tsx
PropTypeDefaultDescription
variant
"solid"|"soft"|"outline"|"ghost"
soft
Visual style. One of `soft`, `solid`, `outline`, `ghost`.
colorScheme
"accent"|"neutral"|"success"|"warning"|"danger"|"info"
neutral
Semantic palette. One of `neutral`, `accent`, `success`, `warning`, `danger`, `info`.
size
"xs"|"sm"|"md"
md
Pixel scale. One of `xs`, `sm`, `md`.
shape
"default"|"pill"|"square"
pill
Outline shape. `default` is gently rounded; `pill` is fully rounded; `square` has no corner rounding.
selected
boolean
false
Toggled / pressed state. Reflected on the button as `aria-pressed`.
onSelectedChange
((selected: boolean) => void)
Invoked with the next selected value when the chip is activated.
leftIcon
ReactNode
Icon rendered before the label.
rightIcon
ReactNode
Icon rendered after the label.
onRemove
(() => void)
Invoked when the trailing remove button is activated.
removeLabel
string
Accessible label for the remove button. Defaults to `Remove {children}` when `children` is a string, otherwise `Remove`.
children
ReactNode
Chip label content.
  • The chip body is a native <button type="button"> with aria-pressed toggled by selected.
  • When onRemove is set, the dismiss control becomes a separate <button> with an accessible aria-label derived from the chip label (or removeLabel if supplied).
  • disabled propagates to both the label and remove buttons, and the wrapper sets aria-disabled for assistive tech.
  • Keep chip text short — single tokens or two-word phrases read best for screen reader users navigating filter lists.
  • Use chips as toggleable filters in faceted search.
  • Combine with an input to build a token-style multi-select.
  • Use shape="square" for compact metadata chips and shape="pill" (default) for filters.
  • Provide a removeLabel for non-string children so the dismiss action stays announced.