Filter menu
A Filter button whose menu lists the fields you can filter by, then each field's values. A Search filters button, or just typing, slides the same menu over to a search across every field and value, like a command menu.
Examples
Views
The popup moves between three views, and each has a state or two.
Inline search
Instead of a Search filters button, the header can be a search box that is always there. Typing turns the menu into results in place, and clearing the text brings the menu back.
Moving between views
Views slide forward going deeper and back coming out, and the popup's height follows its content. A search started inside a field stays within it. With reduced motion, views swap in place.
Applied as chips
The menu only picks filters. Here the app shows each applied field as a chip beside the button, with a button to remove it.
On its own
The menu keeping its own state. Try it from the keyboard: arrows move, Right opens a field, Enter ticks a value, and any letter starts a search.
With an inline search
Your own trigger and wording
Any button can open the menu, such as an icon button in a crowded toolbar. Every piece of text the menu writes can be replaced, for another language.
Anatomy
The trigger opens a popup with a header row and a list. What the header and the list hold changes with the view: the fields, one field's values, or a search.
- Trigger
- Search filters button
- Highlighted field
- Icon
- Count
- Opens its values
- Popup
- Back
- Checkbox
- Value
- Field name
- Highlighted value
- Back
- Group label
- Result
- Search box
- Matched letters
Guidelines
- 01Use it above a list or table that people narrow down by several fields, like issues, orders or files.
- 02Keep field names to one or two words, and order fields by how often people use them.
- 03Order each field's values the way people think of them: a workflow in its order, people by name, sizes from small to large.
- 04Show the applied filters next to the button, such as chips people can remove, so the list never looks mysteriously short.
- 05For a single yes-or-no filter, a switch or a checkbox beside the list is quicker.
Best practices
Showing 3 of 48 issues
Showing 3 of 48 issues
Accessibility
Everything works from the keyboard, one level at a time.
| Key | Does |
|---|---|
| ↑↓ | DoesMoves the highlight |
| → | DoesOpens the highlighted field |
| ↵ | DoesOpens the highlighted field, or ticks the highlighted value |
| Any letter | DoesStarts a search with that letter |
| ←⌫ | DoesWith no search text, goes back to the fields or leaves the search |
| Esc | DoesClears the search, then leaves the field, then closes the menu |
| Tab | DoesMoves between the list and the Search filters button |
- 01When the menu opens, the list takes focus and points at the highlighted row with aria-activedescendant, so screen readers read each row as the arrows move. The Search filters button is one Tab away.
- 02Entering search moves focus into the search box, a combobox that points at the highlighted row the same way. Leaving the search moves focus back to the list.
- 03With the inline search, focus goes to the search box when the menu opens, and stays there.
- 04Values are options in a multi-select listbox, announced as selected or not. Each field is read with how many of its values are chosen and that it opens its values.
- 05A search announces how many results it found.
- 06Escape steps back one level at a time, and the last press returns focus to the Filter button.
- 07Rename every piece of text for your product's language: the trigger with
triggerLabel, the popup withlabel, the search box withsearchLabelandplaceholder, and what only screen readers hear withlabels.
Related components
- Command menuA Cmd+K palette with nested pages, recent commands, ranked search and a preview pane.
- SelectIn fibo's Storybook
- CheckboxIn fibo's Storybook
- Chapter scrubberA rail of marks that swell under the pointer like the Dock, previewing the chapter at the crest.
References
- Base UI Popover, for the popup
- WAI-ARIA combobox pattern
- Motion for React, for the view transitions