- Docs
- Components
- 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
Playground
Every prop, live, and the code it takes.
import { Chip } from "@qeetrix/react/experimental";
<Chip defaultChecked>Starred</Chip>02
On and off
A Chip on its own is a checkbox named by its label: a click or Space turns it on, with the selected tint, a 2px Ember edge and a check.
<Chip>Unread</Chip>
<Chip defaultChecked>Mentions</Chip>03
One of a set
ChipGroup: one value, so the chips are radios. One Tab stop; the arrow keys move the choice, mirrored in right to left. label names the group and isn't shown.
<ChipGroup label="Status" defaultValue="all">
<Chip value="all">All</Chip>
<Chip value="active">Active</Chip>
<Chip value="invited">Invited</Chip>
<Chip value="blocked">Blocked</Chip>
</ChipGroup>04
Several of a set
multiple: each chip a checkbox, and value the chosen ones.
const [departments, setDepartments] = useState(["eng"]);
<ChipGroup label="Departments" multiple value={departments} onValueChange={setDepartments}>
<Chip value="eng">Engineering</Chip>
<Chip value="fin">Finance</Chip>
<Chip value="ops">Operations</Chip>
<Chip value="people">People</Chip>
</ChipGroup>05
Removable
onRemove: a static label ending in a remove button, named "Remove Status: Active". Taking the chip away, and moving focus to the next, is yours.
{filters.map((filter, index) => (
<Chip key={filter} onRemove={() => remove(index)}>{filter}</Chip>
))}06
With an icon
icon: a 16px sharp icon before the label. It takes the check's place, so a chosen chip with one is marked by its tint and edge.
<Chip icon={StarIcon} defaultChecked>Starred</Chip>
<Chip icon={MailIcon}>Unread</Chip>07
Sizes
size: sm for a filter row over a list, md by default, lg at the fields' height. On ChipGroup it sizes every chip.
<ChipGroup label="Status" size="sm" defaultValue="all">…</ChipGroup>
<ChipGroup label="Status" defaultValue="all">…</ChipGroup>
<ChipGroup label="Status" size="lg" defaultValue="all">…</ChipGroup>08
In a narrow column
The chips wrap onto more lines, a small gap apart, and a long label wraps inside its chip: nothing is cut.
<ChipGroup label="Approval" defaultValue="waiting">
<Chip value="waiting">Awaiting approval from the finance team</Chip>
<Chip value="approved">Approved</Chip>
<Chip value="rejected">Rejected</Chip>
</ChipGroup>09
Disabled
disabled greys a chip; a removable one's remove button with it.
<Chip disabled>Archived</Chip>
<Chip disabled onRemove={remove}>Owner: Priya</Chip>10
In Hindi
QeetrixProvider's messages: the remove button is "{label} हटाएँ".
<QeetrixProvider locale="hi-IN" messages={hi}>
<Chip onRemove={remove}>स्थिति: सक्रिय</Chip>
</QeetrixProvider>