Skip to content

Filter toolbar

Every field of a collection as a chip that opens its values, with Clear at the end.

DataFilter
npx shadcn@latest add @silicon-ui/filter-toolbar

Installation

With the shadcn CLI

npx shadcn@latest add @silicon-ui/filter-toolbar

Manually

  1. Install the dependencies

    npm install lucide-react motion
  2. Copy 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
  3. Add the foundation, once per app, for the design and motion tokens

    npx shadcn@latest add @silicon-ui/silicon-foundation

Usage

usage.tsx
import { FilterToolbar } from "@/components/silicon-ui/filter-toolbar/filter-toolbar";

API reference

FilterToolbar

PropTypeDefault
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—
onClearAll

Called by Clear, which shows once anything is set. Leave it out to hide Clear.

() => void—
children

More controls at the end of the line, before Clear (a sort, a view switch).

ReactNode—
label

The line's name for screen readers. Defaults to "Active filters".

string"Active filters"
addFilter

The 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

PropTypeDefault
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—
active

Applied filters. Each field shows its current value and the value step marks it.

FilterChip[][]
labelstring"Add filter"
align

The trigger edge the panel lines up with. It flips or shifts when the viewport, or a clipping ancestor, has no room.

"start" | "end""end"

Dependencies

npm
lucide-reactmotion
Registry
silicon-motion-tokenschipbutton