FilterChip
BasicSelection
<co-filter-chip>FilterChip toggles a quick filter above a list, such as Rejected or Needs Review, and can show a count.
import { FilterChip } from 'health-components';
Examples
Showcase
Removable
Without Check
Disabled
Usage
<FilterChip selected={f.rejected} count={12} onChange={on => setF({ ...f, rejected: on })}>Rejected</FilterChip>
When to use
- Quick filters over a table or queue.
- Removable active filters (with onRemove).
When not to use
- Mutually exclusive views: SegmentedControl or Tabs.
Variants and states
| Variant | What it is |
|---|---|
| off | Outlined pill. |
| on | Primary fill with check. |
| count | Number bubble. |
| removable | x button to clear. |
| disabled | 45% opacity. |
Accessibility
- aria-pressed shows the state; the check icon adds a non-colour cue.
Do and don't
- Do: "Rejected 12" over the claims queue.
- Don't: Chips that each open a different screen.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children * | ReactNode | — | Label. Required |
selected | boolean | — | On state (controlled) |
defaultSelected | boolean | false | Initial on state (uncontrolled) |
count | number | none | Count after the label |
check | boolean | true | Show the check icon when on |
onRemove | () => void | none | Makes a removable (applied) chip with an x button |
removeLabel | string | "Remove filter <label>" | Accessible name of the remove button |
onChange | (on: boolean) => void | none | Called with the new state |
Also accepts native attributes, including defaultChecked, defaultValue, autoFocus, disabled, name, value, plus className and event handlers on the root element.
Angular, Vue and HTML
Register the elements once (Angular guide), then use <co-filter-chip>. Attributes take strings; arrays and objects are set as properties (Angular [prop], Vue :prop) or as JSON attributes. Callbacks are DOM events with the value in event.detail.
Angular template
<co-filter-chip selected default-selected [defaultValue]="defaultValue" (co-remove)="onRemove($event.detail)">…</co-filter-chip>
| Kind | Name | Description |
|---|---|---|
| attribute | selected | On state (controlled) |
| attribute | default-selected / defaultSelected | Initial on state (uncontrolled); default false |
| attribute | count | Count after the label; default none |
| attribute | check | Show the check icon when on; default true |
| attribute | remove-label / removeLabel | Accessible name of the remove button; default "Remove filter <label>" |
| attribute | default-checked / defaultChecked | |
| property / JSON attribute | default-value / defaultValue | |
| attribute | auto-focus / autoFocus | |
| attribute | disabled | |
| attribute | name | |
| property / JSON attribute | value | |
| event | co-remove | Makes a removable (applied) chip with an x button; default none (React: onRemove) |
| event | co-change | Called with the new state; default none (React: onChange) |
| slot | (default) | Label. Required |