Skip to content

Chips

Edit on GitHub

Chips are compact elements that allow users to refine content, such as filtering categories or tags, with immediate visual feedback.

@volvo-cars/css v3.3.1

Use the chip-selectable and chip-dismissible CSS classes with the ARIA state required by each interaction pattern.

Show codeHide code
import { useState } from 'react';
const options = ['Hybrid', 'Electric', 'Petrol'];
export function ChipSelectable() {
const [selected, setSelected] = useState<string[]>([]);
const toggle = (option: string) => {
setSelected((prev) =>
prev.includes(option)
? prev.filter((s) => s !== option)
: [...prev, option],
);
};
return (
<div className="flex gap-8">
{options.map((option) => (
<button
key={option}
type="button"
className="chip-selectable"
aria-pressed={selected.includes(option)}
onClick={() => toggle(option)}
>
{option}
</button>
))}
</div>
);
}

Use chip-selectable on a <button>. Toggle selection with aria-pressed.

Add data-size="small" for a compact variant.

For mutually exclusive selection, add role="radiogroup" on the container and role="radio" on each button. Use aria-checked instead of aria-pressed.

Use chip-dismissible on a <div> containing text and a dismiss button. The dismiss button must use slot="dismiss" for correct styling. Use IconButton from @volvo-cars/react-icons with variant="clear" and bleed for the dismiss action.

For a set of removable items, add role="list" on the container and role="listitem" on each chip.

Set data-loading="true" and aria-busy="true" on the chip container. The dismiss button is automatically hidden and a <progress class="spinner"> takes its place.

Class Description
chip-selectable Chip for toggling a selection. Use on a <button>.
chip-dismissible Chip with a dismiss button. Use on a <div> containing text and a slot="dismiss" button.
Attribute Applies to Description
data-size="small" Both Compact variant, 2rem tall.
aria-pressed="true" chip-selectable Selected state for multi-select chips. Shows a checkmark.
aria-checked="true" chip-selectable with role="radio" Selected state for single-select chips. Shows a checkmark.
disabled, aria-disabled="true" Both Dims the chip and disables pointer events.
data-loading="true" chip-dismissible Hides the dismiss button and positions a .spinner in its place.
slot="dismiss" Dismiss button Marks the dismiss button inside chip-dismissible.

Key responsibilities from the WCAG audits (selectable, dismissible):

  • Use the right ARIA pattern: aria-pressed for multi-select toggles, aria-checked with role="radio" for single-select. Dismissible chips need a dismiss <button> with a descriptive aria-label (e.g. “Remove EX90”).
  • Loading states: use aria-busy="true" and a <progress> element with aria-label so screen readers announce the loading state.
  • Keyboard: all chips must be focusable and activatable via Enter or Space. Tab order should follow visual order (left-to-right, top-to-bottom).
  • Contrast: text and background contrast in both selected and unselected states needs verification (WCAG 1.4.3, pending audit).
  • No unexpected side effects: selecting or dismissing a chip should not cause disorienting changes elsewhere on the page.
  • Target size: chip and dismiss button target sizes should be at least 40×40px. The small and large variants both provide a 40px interaction target.

Chips target size