Filters
Narrows a long list to the records a person needs, and always shows what is narrowing it.
Filtering turns a long list into the short one a person came for. This page decides how filters are offered, how an applied filter is shown, and how people get back to the full list.
The problem
A list of 200 work items is useless until it is narrowed, but a narrowed list is dangerous when the narrowing is invisible. People report missing records that were only hidden by a filter they set last week. A filter pattern has to make narrowing easy, keep every applied filter in view and make undoing it one press.
Anatomy
| Part | Component | Job |
|---|---|---|
| Search | Input Group | Matches text in the record. |
| Faceted filter | Dropdown Menu with multiple selection | Chooses several values of one property. Shows a count when it has values. |
| Facet panel | Checkbox, Slider and Switch in a Field | The same choices, always visible, for catalogues with many facets. |
| Active filters | Button as a chip with a remove icon | Shows each applied value and removes it. |
| Reset | Button, ghost | Clears search and every filter at once. |
| Result count | A status line | Says how many of how many records are shown. |
| Results | Item rows | The records, with a state square. |
| Nothing found | Empty | Says that nothing matches and offers Reset filters. |
| Small-screen panel | Sheet | Holds the facet panel below 1024px. |
Blocks
Filter bar
filters-01 puts search and three faceted filters in a bar above the results: site, department and status. Each filter is a menu where you tick several values. Every applied value appears as a chip that removes itself, with a Reset filters button. The count above the results reads "6 of 18 work items", and a search with no match shows an empty state with a way back.
Choose it when there are up to four facets with short lists of values, and the results take most of the page.
Facet panel
filters-02 keeps the facets visible in a column beside the results: category and material as checkbox groups, a price range slider and an in stock switch. A Sort by select orders the results. Below 1024px the panel moves into a sheet opened by a Filters button that shows the number of active filters.
Choose it for catalogues where people compare options across many facets and want to see all of them at once.
Behaviour
States
- Applying: results update as soon as a value changes. There is no Apply button for a list this short. For a server query that takes seconds, show a Spinner in the count line and keep the old results until the new ones arrive.
- Active: a filter with values shows its count on the button. Each value is a chip.
- Reset: Reset filters appears only when something is applied.
- No results: the list is replaced by an empty state that says nothing matches, and offers Reset filters.
- One crimson square: results may carry state squares, but the screen has one crimson square at most.
Responsive behaviour
| Width | Filter bar | Facet panel |
|---|---|---|
| 1280px and wider | Search and filters on one line. | Panel in a 16rem column beside the results. |
| 1024px to 1279px | Search and filters on one line. | Same as above. |
| 640px to 1023px | Search and filters on one line, and the filters wrap if they need to. | Panel moves into a sheet. A Filters button shows the number of active filters. |
| Below 640px | Search above the filters, which wrap. Chips wrap. | Same as above. The sheet footer shows how many results the filters give. |
| 320px | Same as below 640px. Chips wrap onto as many lines as they need. | Same as below 640px. |
Keyboard and focus
| Key | Action |
|---|---|
| Tab | Moves through the search field, each filter, each chip and Reset filters. |
| Enter | Opens the focused filter menu, or removes the value of the focused chip. |
| Arrow Down | Moves to the next value in an open filter menu. |
| Space | Ticks or clears the focused value or checkbox. |
| Arrow Right | Raises the focused slider thumb by one step. |
| Esc | Closes the open filter menu or the facet sheet. |
A filter menu stays open while you tick several values, so one visit is enough to set a facet.
On a phone
filters-01 puts pointer-coarse:touch-controls on the search and filter row and on the filter menus. The active filter chips stay compact, so they wrap in fewer lines. filters-02 puts it on the results toolbar (the Filters button and the sort select) and on the filter sheet, where each checkbox row becomes 44px. See Sizing.
Accessibility
- Wrap the search and filters in a region with
role="search"and a label. - Name each filter menu group, and give each chip a name that says what it removes:
Remove filter Site: Bergamo. - Announce the result count with
role="status", so a screen reader hears "6 of 18 work items" after each change. - Label each slider with what it measures, and show its current range as text next to it.
- A count on a button needs a text equivalent for screen readers, such as "2 selected".
- Never rely on the chip colour. The chip carries the facet name and the value in words.
Content
- Name a filter after the property, in sentence case: Site, Department, Status.
- Name values the way records name them: Bergamo, In progress, Blocked.
- Chips read as "Facet: value" so each chip makes sense alone.
- The empty state says what happened and what to do: "No work item matches. Remove a filter or search for something broader."
- Order the values by how often they are used, or alphabetically when there is no better order.
1 of 18 work items
1 of 18 work items
Show every applied filter as a chip with a remove control, and say how many records remain out of how many.
1 work item
Don’t narrow a list silently. A count with no sign of the filter that caused it reads as missing data.
Install
pnpm dlx shadcn@latest add @silkware/filters-01pnpm dlx shadcn@latest add @silkware/filters-02