Skip to content
Thrum

Filter bar

A row of filters above a table or a chart: a search field, a chip for each filter that opens a small panel of options or a range, and saved views. It holds plain data, so the parent filters its own rows. For one choice between a few views, a segmented control is enough.

Install

npx shadcn@latest add @thrum-pro/filter-bar

This is a Pro component. The command works once your project has a licence key: set up Pro or see pricing.

Automatically installs icons plus and x from the icon set.

Data shape

Type
type FilterValue = readonly string[] | readonly [number, number];
type Filters = Readonly<Record<string, FilterValue>>;
Sample
const filters: Filters = {
  status: ["active", "trial"],
  seats: [20, 100],
};

Props

PropTypeDefaultDescription
fieldsreadonly FilterField[]RequiredThe filters, in order. An options field has key, label and options; a range field has key, label, min, max, and an optional step and format.
filtersFilters–The set filters, when the parent holds them. Use it with onFiltersChange.
defaultFiltersFiltersDefault {}The filters at first, when the bar holds them itself.
onFiltersChange(filters: Filters) => void–Called with every set filter when one changes. Unset fields are left out, and options keep the fields' order.
searchstring–The search text, when the parent holds it. Use it with onSearchChange.
defaultSearchstringDefault ""The search text at first, when the bar holds it itself.
onSearchChange(search: string) => void–Called with the text on every change, including when it is cleared.
searchLabelstringDefault "Search"The search field's name for screen readers. An empty string draws no search field.
searchPlaceholderstringDefault "Search"Shown in the empty search field.
viewsreadonly SavedView[]–Saved views: value, label, filters and an optional search. Picking one sets them. The view that matches the current state shows as selected; none does after a change by hand.
onViewChange(value: string) => void–Called with the value of a picked view.
localestringDefault "en-US"The locale that prints range values.
soundbooleanDefault truePlay a rising click when an option is ticked and a falling one when a filter is removed, if the visitor has sound on.
classNamestring–Extra classes for the root, merged last.
isActive(), cleanFilters()functions–More exports: whether a field's value filters anything, and the set filters in a fixed order, for comparing two states.

Motion and sound

Motion

  • A filter's panel fades and grows from 96% over 150 ms, from the chip it belongs to.
  • Chips, ticks and the saved-view thumb change over 150 ms.
  • Reduced motion: everything changes at once.

Sound

  • A rising click when an option is ticked, a falling one when it is cleared, when a chip is removed, and on Clear all.
  • A soft tone when a filter's panel opens and closes; a tick as a range thumb crosses a step; a click when a saved view is picked.

Sound is off until the visitor turns it on. Pass sound={false} to keep this component silent. How sound works

Accessibility

  • Each chip is a button named by its field and its values, such as Status, Active, Trial, and it says that it opens a dialog. Its remove button is named Remove Status filter.
  • When a chip is removed the focus stays on the chip, which is now empty; Clear all moves it to the first chip.
  • A polite line, read by screen readers only, repeats the filters after every change.
  • Options are checkboxes named by their visible text. A range is two slider thumbs named Lowest and Highest with the field's name.
  • A set filter is a solid chip with its values written out; an unset one is dashed with a plus, so the state does not rest on colour.
  • The panels are floating surfaces. Under a glass material their tint keeps text at 4.5 to 1, and every control sits 8 pixels inside the edge.
KeysAction
TabMove through the saved views, the search field, the chips with their remove buttons, and Clear all.
Enter / SpaceOn a chip: open its panel. The focus moves into it.
SpaceIn a panel: tick or clear the focused option.
← / → / Home / EndOn a range thumb: move it one step, or to an end. On the saved views: pick the next or previous view.
EscClose the panel. The focus returns to its chip. In the search field, Escape clears the text.

Source

SourcePro

The source comes with Pro

TypeScript source · Copy-paste ready · MIT-compatible for client projects · Includes all dependencies

Files and dependencies

Adds
components/ui/filter-bar.tsx
Packages
None
Brings along
ButtonCheckboxPopoverSearch fieldSegmented controlSliderSound engine
Icons
plusx

Changelog

  1. 1.0.0 · 2026-12-03First release.

Loading index…

Keyboard shortcuts

/Ctrl KSearch components, docs and actions
?Show this list
AAppearance studio
SSound on or off
MFull or reduced motion
TTheme: auto, light, dark
GSurface: solid or frosted
BBackdrop photograph (under glass)
CCorner radius: square to round
RReplay the demo, on a component page
DDraw new data, on a component page
←→HomeEndMove the cursor in a focused chart
EscClose a dialog, or leave a chart cursor