Filter chip
One applied filter on a list: what is filtered, how, and by which value, with an x to remove it.
<FilterChip label="Status" icon={Pulse} condition="is" value="Suspended" marks={[{ status: "warning" }]} onConditionClick={openConditions} onValueClick={openValues} onRemove={remove}/>Installation
import { FilterChip } from "@dome-systems/ds-dashboard/components";A page does not draw each chip: it places FilterChips, which draws one chip per filter that is on, then + and Clear. See the Table's page. FilterChip is the chip alone, by what it draws.
Anatomy
- 1 — Label. What is filtered, with its icon. It does nothing, and is set a step quieter than the rest.
- 2 — Condition. How: "is", "is any of", "contains". A button when it can change.
- 3 — Value. By which value, after its marks. A button, and the one part whose words are cut when they are too long.
- 4 — x. Removes the filter.
Three parts
What is filtered, how, and by which value, then the x. The label does nothing. The condition and the value are buttons: a list's filters open a menu from each. A chip is 24px tall, with 12px type and 12px icons.
<FilterChip label="Status" icon={Pulse} condition="is" value="Suspended" marks={[{ status: "warning" }]} onConditionClick={openConditions} onValueClick={openValues} onRemove={remove}/>One part
parts={1} is the value and the x, for a filter that is on or off: there is no other value to pick, so nothing opens. Its label is not drawn; it still names the chip and its x.
<FilterChip parts={1} label="Show violations" value="Violations only" marks={[{ icon: ExclamationCircleFill, color: "warning" }]} onRemove={remove}/>A status's dot
A status mark is the Status dot in a Badge color, in a small tint of that color. A filter that holds several values says their count ("3 statuses") after their dots; in a list's row, the names are in the value's tooltip.
<span className="flex flex-wrap items-center justify-center gap-3"> <FilterChip label="Status" icon={Pulse} condition="is" value="Active" marks={[{ status: "success" }]} onConditionClick={openConditions} onValueClick={openValues} onRemove={remove} /> <FilterChip label="Status" icon={Pulse} condition="is any of" value="3 statuses" marks={[{ status: "success" }, { status: "warning" }, { status: "error" }]} onConditionClick={openConditions} onValueClick={openValues} onRemove={remove} /></span>Avatars
An avatar mark is a face the page hands in, an AvatarFace. The AvatarGroup draws them, at its 16px size: each over the one before it, the one behind cut around the next (it keeps 11 of its 16px) with its edge following the cut. The chip does nothing of its own to them: it hands every avatar to the group, which behaves as it does everywhere. By default that is three avatars, then the group's count for the rest ("+1"). avatarGroup hands the group its own max, size and tooltip. 16px and 20px fit the 24px chip (4px and 2px above and below); at 24px an avatar touches the chip's edge, and a larger one sticks out of it.
<span className="flex flex-wrap items-center justify-center gap-3"> <FilterChip label="Owner" icon={Building} condition="is" value="Maya Okafor" marks={[{ avatar: <AvatarFace name="Maya Okafor" /> }]} onConditionClick={openConditions} onValueClick={openValues} onRemove={remove} /> <FilterChip label="Owner" icon={Building} condition="is any of" value="4 owners" marks={[ { avatar: <AvatarFace name="Maya Okafor" /> }, { avatar: <AvatarFace name="Jonas Weber" /> }, { avatar: <AvatarFace name="Priya Raman" /> }, { avatar: <AvatarFace name="Lucas Ferreira" /> }, ]} onConditionClick={openConditions} onValueClick={openValues} onRemove={remove} /></span>An icon mark
An icon mark is 12px: gray like the chip's other icons, or in an intent's text color with a color. The chip itself stays neutral: only the value's mark takes a color.
<span className="flex flex-wrap items-center justify-center gap-3"> <FilterChip label="Type" icon={ShapesSquareCircle} condition="is" value="Managed" marks={[{ icon: ShapesSquareCircle }]} onConditionClick={openConditions} onValueClick={openValues} onRemove={remove} /> <FilterChip parts={1} label="Show violations" value="Violations only" marks={[{ icon: ExclamationCircleFill, color: "warning" }]} onRemove={remove} /></span>No mark
A text, a number or a date has no mark: the value is its words.
<span className="flex flex-wrap items-center justify-center gap-3"> <FilterChip label="Name" icon={TextAa} condition="contains" value="“billing”" onConditionClick={openConditions} onValueClick={openValues} onRemove={remove} /> <FilterChip label="Created" icon={Calendar} condition="after" value="1 week ago" onConditionClick={openConditions} onValueClick={openValues} onRemove={remove} /></span>A condition that cannot change
Without onConditionClick the condition is text, set like the label, and nothing opens from it. A filter that has one condition says it this way. With no condition at all, a chip draws no middle part.
<FilterChip label="Type" icon={ShapesSquareCircle} condition="is" value="Managed" onValueClick={openValues} onRemove={remove} />A long value
A chip is 320px at most, and its value's words 200px. The value is what gives way: it is cut with an ellipsis and says itself whole in a tooltip. The label and the condition are never cut: if they need more than 320px by themselves, they keep their room. Alone, a chip keeps its full width; in a list's row it gives up its value's width first, down to 24px, before the row wraps.
<FilterChip label="Name" icon={TextAa} condition="does not contain" value="“compliance-evidence-collector-production-eu-west”" onConditionClick={openConditions} onValueClick={openValues} onRemove={remove}/>In the dashboard
Where the dashboard shows a Filter chip today: under the toolbar of the two lists on the design system's Table. No screen's filter has avatars yet. The other filtered lists still draw older chips of their own: Audit and Rules (components/shared/filters.tsx), and Callers and the Guards' filters (components/reui/filters).
The Agents list's filters
Under the list's toolbar, one chip per filter that is on: Status, Created, Last active, and Type where managed agents are on. The Filters draw them from the list's fields; they give the value its menu, and the condition one where the field has more than one.
components/agents/agent-table.tsx, ds/components/filters.tsx (FilterChips)
An on/off filter
The Agents list's Show violations is a switch in the Filter menu. On, its chip is one part: “Violations only”, with the filled “!” in the warning text color.
components/agents/agent-table.tsx
The Devices list's filters
Status, Created and Last active: the Agents list's fields without Type and Show violations.
app/(authenticated)/[kind]/[scopeId]/devices/page.tsx
Accessibility
A chip is a group named by its label ("Status filter"). In a chip of three parts the keyboard stops on the condition (when it is a button), the value and the x, in that order; the label is text. Their names say what they are: "Condition: is", "Value: Suspended", "Remove the Status filter".
In a chip of one part the keyboard stops on the x alone, and on the value too when it is cut, so the keyboard reaches its tooltip. The label is not drawn, and still names the group and the x ("Remove the Show violations filter").
The marks are hidden from a screen reader. For one value, the words say what its mark shows; for several, the words give their count only ("3 statuses"). A value that is cut says itself whole in a tooltip, under the pointer and on keyboard focus.
API Reference
FilterChip
Besides these, the props of a <div>, except children.
| Prop | Type | Default | Description |
|---|---|---|---|
parts | 1 | 3 | 3 | 3: label, condition, value. 1: the value alone, with its marks. Both end with the x. |
label | string | — | Required. What is filtered. A one-part chip does not draw it, and is still named by it. |
icon | IconComponent | — | The label's icon, before it. Not drawn in a one-part chip. |
condition | string | — | The middle part's words: "is", "is any of", "contains". Without it there is no middle part. |
value | string | — | Required. The last part's words. |
marks | readonly FilterChipMark[] | — | What stands before the value's words. Three dots or icons are drawn at most; avatars all go to the Avatar group, which draws three and counts the rest. |
avatarGroup | Pick<AvatarGroupProps, "max" | "size" | "tooltip"> | — | For marks that are avatars: the Avatar group's own settings, handed on as they are. max is how many are drawn before the group's count ("+2"): 3 unless set, the group's own default. size is the group's size (xxxs, 16px, unless set; 16 and 20px fit the chip). tooltip is each avatar's name on hover (off). |
onConditionClick | () => void | — | With it the condition is a button. Without, it is text and does nothing. |
onValueClick | () => void | — | The value's press, in a chip of three parts. |
onRemove | () => void | — | The x's press. The x is always drawn. |
Marks
What stands before the value's words. Each mark is one of three kinds.
| Prop | Type | Default | Description |
|---|---|---|---|
status | BadgeColor | — | A status's dot in that Badge color. |
dot | Omit<StatusDotSpec, "color"> | — | Beside status: the Status dot's own settings (its size, its halo, its pulse). |
avatar | ReactNode | — | A face the page draws. It fills the 16px round box it is given. |
icon | IconComponent | — | An icon at 12px, gray. |
color | BadgeColor | — | Beside icon: sets it in that intent's text color. |
Tokens
In ds/tokens/filters.css. The chip is a secondary Button group at xs (24px), so the rest of its look is the Button group's.
| Token | Value | What it sets |
|---|---|---|
--filter-chip-field-foreground-text | gray-1400 — dark gray-1200 | The label and its icon, and a condition that is text: a step under the secondary text. |
--filter-chip-part-foreground-text | --neutral-fg-secondary | The condition, the value and the x at rest. |
--filter-chip-part-hover-foreground-text | --neutral-fg | The same three under the pointer and while their menu is open. A one-part chip's value is always in it. |
--filter-chip-shadow | a 1px ring — dark the secondary button's shadow | The chip's edge: flat in light, the secondary button's whole edge in dark. |
--filter-value-{color}-foreground-icon | --{color}-fg-secondary — fuchsia --badge-fuchsia-dot | An icon mark with a color: that intent's text color. |
--filter-chip-halo-{color} | the Badge's tint — dark lighter for four | The tint around a status's dot. |
Rules
Written down
The chip stays neutral; a value carries its own color
A value's mark is in its own color, in the value's part of the chip. The chip itself is never colored.
From ds/README.md (Filters).
A mark is a status's dot, an avatar or an icon, three at most
More than three is said by the value's words ("4 owners"). A status is drawn by the Status dot, as the Table's statuses are.
From ds/components/filter-chip.tsx and ds/README.md (Filters).
The label does nothing, so it is quieter
The label is a step under the secondary text. The condition, the value and the x, which open or act, are in the secondary text, and in the full text color under the pointer and while open.
From ds/tokens/filters.css and ds/README.md (Filters).
The value is what gives way
A chip is 320px at most and its value's words 200px. The value is cut with an ellipsis and whole in a tooltip; the label and the condition are never cut.
From ds/components/filter-chip.tsx and ds/README.md (Filters).
An on/off filter is one part
Its value and the x, with no condition and nothing to open. Its row in the Filter menu says what to do ("Show violations") and its chip what is done ("Violations only"): two strings.
From ds/README.md (Filters).
No empty chip
A chip is there once its filter holds a value. Emptied from the Filter menu it goes at once; emptied from its own menu it stays until that menu closes.
From ds/README.md (Filters).
Flat in light, the button's edge in dark
In light a chip has the secondary button's 1px ring and no drop under it. In dark it has the secondary button's whole edge.
From ds/tokens/filters.css.
A chip's people are the Avatar group
A chip's avatars are the AvatarGroup, at 16px unless the page says another size. The overlap, the cut and the edge along the cut are the group's own, and so are its max of three and the count after them: the chip never cuts, hides or counts an avatar itself.
From ds/components/filter-chip.tsx.