Skip to main content
  1. Docs
  2. Components
  3. Data display

Chip

An interactive tag: one that turns on and off, such as a filter, or a choice already made with a button that removes it.

Import
@qeetrix/react/experimental
Status
ExperimentalSince 0.4.0
Renders
<span role="checkbox">Server-rendered
Tested
WCAG 2.2 AAaxe on every pull request

01

Import

chip.tsx
// Experimental: from the package's experimental entry, until it's stable.
import { Chip, ChipGroup } from "@qeetrix/react/experimental";

02

Props

And every native attribute of the element it renders.

PropTypeDefaultWhat it does
childrenReactNoderequiredThe label. A string also names a removable chip's remove button.
iconIconSource—A 16px sharp icon before the label; a selectable chip with one shows no check.
size"sm" | "md" | "lg""md", or the group'sThe controls' heights: sm for a filter row over a list, lg the fields'.
checked · defaultCheckedboolean— · falseSelectable: on or off, as Base UI's Checkbox. Not in a one-value ChipGroup, whose value says which.
onCheckedChange(checked, details) => void—Called with the new state.
valuestring—In a ChipGroup, the value it stands for.
disabledbooleanfalseGreys it; on a removable chip, its remove button too.
onRemove() => void—Makes it removable: a static label ending in a remove button. Taking it away, and moving focus, is yours.
removeLabelstring"Remove {label}"The remove button's name, for a label that isn't plain text.
messages{ remove?, removePlain? }the provider'sA removable chip's strings: "Remove {label}", and "Remove" for a label that isn't text.
ChipGroup: labelstringrequiredNames the group for assistive technology, "Status". It isn't shown.
ChipGroup: multiplebooleanfalseSeveral values, the chips checkboxes; otherwise one, the chips radios.
ChipGroup: value · defaultValuestring, or string[] with multiple—The chosen value, or values, as Base UI's RadioGroup and CheckboxGroup.
ChipGroup: onValueChange(value, details) => void—Called with the new value, or values.
ChipGroup: size"sm" | "md" | "lg""md"Every chip's size.
ChipGroup: disabledbooleanfalseDisables every chip.

03

Parts

Each part carries a data-slot, for tests and placement.

data-slotElementWhat it is
chip-group<div role="radiogroup">role="group" with multiple; aria-label from label.
chip<span role="checkbox">role="radio" in a one-value group; aria-checked, data-checked, data-size. A removable chip is a <span> with data-removable.
chip-check<span>The check, while chosen, without an icon.
chip-icon<svg>The icon, aria-hidden.
chip-label<span>The label.
icon-button<button>A removable chip's remove button: aria-label "Remove {label}".

04

Filters over a list

A one-value group, sm, in the toolbar of the table it filters.

users.tsx
const [status, setStatus] = useState("all");
const shown = status === "all" ? users : users.filter((user) => user.status === status);

<Table
  label="Users"
  rows={shown}
  columns={columns}
  rowId={(user) => user.id}
  rowLabel={(user) => user.name}
  toolbar={
    <ChipGroup label="Status" size="sm" value={status} onValueChange={setStatus}>
      <Chip value="all">All</Chip>
      <Chip value="active">Active</Chip>
      <Chip value="invited">Invited</Chip>
    </ChipGroup>
  }
/>

05

In a form

A one-value group posts its value under name. With multiple, give each chip the name: the group takes none.

invite.tsx
<ChipGroup label="Plan" name="plan" defaultValue="growth">…</ChipGroup>

<ChipGroup label="Departments" multiple defaultValue={["eng"]}>
  <Chip name="departments" value="eng">Engineering</Chip>
  <Chip name="departments" value="fin">Finance</Chip>
</ChipGroup>

06

A bar of applied filters

Tags under a toolbar with Clear all, a summary of what's left, and focus moved for you: FilterTags.

applied-filters.tsx
import { FilterTags } from "@qeetrix/react/experimental";

<FilterTags
  filters={[{ id: "status", label: "Status", value: "Active" }]}
  onRemove={removeFilter}
  onClear={clearFilters}
  summary="412 of 1,284 users"
/>
Next — ChipAccessibility