All filters
Every filter in one panel: a list with the values set on each, and the picked filter open beside it.
Live example
Filters
19 carsCopy
Add the "All filters" filter from FiltersUI to this project. It is free and MIT licensed, from filtersui.com. If this project has a components.json, run: npx shadcn@latest add https://filtersui.com/r/all-filters.json Otherwise read https://filtersui.com/r/all-filters.json: it holds the files with the path to save each one at, and lists any other FiltersUI items it needs. How it works, its props and an example: https://filtersui.com/filters/all-filters When done, run the app, tell me which page to open, and show me the value changing as I use the filter.
What it does
- The picked row is tinted, and the filter on the right rises in from a blur.
- Each row carries its values as chips; a new chip grows in, and a removed one collapses while the rest close up.
- The find box narrows the list by name or other words ("mileage" finds Kilometres) and marks the letters it matched.
- Below 520px wide the list and the filter take turns: a row slides its filter in, Back slides the list back.
Keyboard
- Tab runs the head, the find box, the list (one stop) and then the picked filter.
- In the list, Up and Down move between rows, Home and End jump, Enter or Space picks; Down in the find box enters the list, Enter picks the first match.
- On a narrow panel, picking moves focus to Back, and Back or Escape returns to the row.
- Clear moves focus to the filter's first control; Clear search moves it to the find box.
- While disabled Tab reaches only Show; in an error Tab reaches Retry after the list.
Props
Value. None of its own: each entry shows a filter you keep in your own state. picked is the id of the filter open on the right.
| Prop | Description |
|---|---|
groupsRequired | The list, in groups such as "Price and age". readonly { label: string; filters: FilterEntry[] }[] |
FilterEntryRequired | One filter in a group: its name, a short line under its title, more words for the find box, its set values, Clear, and the filter itself. { id, label, hint?, keywords?, values?, onClear?, content } |
FilterEntry.valuesOptional | What is set, one chip each in the list with its own cross. Empty means unset. color draws a small swatch. readonly { key: string; label: string; onRemove: () => void; color?: string }[] |
picked / defaultPicked / onPickedChangeDefault none picked | The filter open on the right, controlled or not. string | null / string | null / (id: string | null) => void |
onClearAllOptional | Clears every filter, from the "3 set" chip in the head. () => void |
showLabel / onShowDefault "Done" | The head's button, e.g. "Show 34 cars". string / () => void |
title / headingLevelDefault "Filters" / 2 | The head's title; the picked filter's title sits one level below. string / 2 | 3 |
findLabel / heightDefault "Find a filter" / 560 | The find box's words, and the height of the two columns in px from 520px wide. string / number |
localeDefault "en-US" | Formats the "3 set" count, e.g. "ar-EG". Words stay English. string |
statusDefault "ready" | "loading" draws placeholders the size of the real content, so nothing moves when the data arrives; "error" shows errorText and a Retry button in its place. "ready" | "loading" | "error" |
onRetryOptional | Called by Retry in the error state. Without it the error line has no button. () => void |
errorTextDefault "Couldn't load the options." | The error line, in plain words. string |
disabledDefault false | Dims the list and the picked filter and blocks their input; Show stays, and the "3 set" chip, Clear and the chips' crosses are left out. boolean |