Filter toolbar
Every field of a collection as a chip that opens its values, with Clear at the end.
npx shadcn@latest add @silicon-ui/filter-toolbarInstallation
With the shadcn CLI
npx shadcn@latest add @silicon-ui/filter-toolbarManually
Install the dependencies
npm install lucide-react motionCopy these files into your project
- components/silicon-ui/filter-toolbar/filter-toolbar.tsx
- components/silicon-ui/filter-toolbar/filter-toolbar.module.css
Shared with other components. Skip any you already have.
- components/silicon-ui/lib/fluid-hover.tsx
Add the foundation, once per app, for the design and motion tokens
npx shadcn@latest add @silicon-ui/silicon-foundation
Usage
API reference
FilterToolbar
| Prop | Type | Default |
|---|---|---|
filters*The applied filters, one per field: `id` is the field's id, `label` its name, `value` the value's label. | FilterChip[] | — |
onRemove*Called with a field's id when its filter is removed (Any in its menu, or pressing a chip with no field). | (id: string) => void | — |
onClearAllCalled by Clear, which shows once anything is set. Leave it out to hide Clear. | () => void | — |
childrenMore controls at the end of the line, before Clear (a sort, a view switch). | ReactNode | — |
labelThe line's name for screen readers. Defaults to "Active filters". | string | "Active filters" |
addFilterThe fields, each shown as a chip that opens its values; `onAdd` receives the picked value as a chip whose id is the field's id, so a second pick replaces the first. `label` and `align` are for FilterMenu and do nothing here. | { fields: FilterField[]; onAdd: (filter: FilterChip, field: FilterField) => void; label?: string; align?: "start" | "end" } | — |
FilterMenu
| Prop | Type | Default |
|---|---|---|
fields* | FilterField[] | — |
onSelect*Receives a chip whose id is the field id, so a second pick for a field replaces the first. | (filter: FilterChip, field: FilterField) => void | — |
activeApplied filters. Each field shows its current value and the value step marks it. | FilterChip[] | [] |
label | string | "Add filter" |
alignThe trigger edge the panel lines up with. It flips or shifts when the viewport, or a clipping ancestor, has no room. | "start" | "end" | "end" |