Filter controls
Compact controls for table filters, such as filter tokens, a menu to add filters, a column picker and reset actions.
Select Adicionar filtro to add the Cliente filter, open a token to choose values, and use the × or Limpar filtros to remove them.
When to use
- Above a table or a list that operators filter often: tarefas by status, cliente and prazo.
- When filters are optional and added one at a time, so the toolbar stays short.
- When the operator must see the applied filters at a glance, with the selected values.
When not to use
- A form with many fields and a submit button. Use form fields.
- One exclusive choice shown as tiles or badges. Use Radio filter.
- A single closed list inside a form. Use Select.
- Choosing a date range inside a form. Use Date range.
The parts
Each part is a separate import. The caller keeps the filter values, the permissions, the persistence and the translations.
| Part | Import | Role |
|---|---|---|
ChoiceFilter |
@repo/ui/choice-filter |
A multi-choice filter as a token or a button, with reset and selection tooltip. |
FilterTokenTrigger |
@repo/ui/filter-token-trigger |
The token button: name, a divider, the selected value and a +N counter. |
FilterReset |
@repo/ui/filter-reset |
Wraps a filter trigger and adds a × button to remove it. |
AddFilterMenu |
@repo/ui/add-filter-menu |
A menu of the filters that are not applied yet. |
ColumnsControl |
@repo/ui/columns-control |
An icon button with a checkbox menu to show or hide columns. |
ResetFiltersButton |
@repo/ui/reset-filters-button |
A divider and a button that clears every filter. |
FilterToolbar |
@repo/ui/filters |
Badges for the filters applied, with a tooltip for many values. |
SelectFilter, MultiSelectFilter, DateRangeFilter |
@repo/ui/filters |
Editors for one filter: a single choice, many choices and a date range. |
Variants
ChoiceFilter has two looks. Use token in a toolbar of applied filters and default where filters are plain buttons.
Token
Button
| Variant | Use for |
|---|---|
default |
A filter button with the label and the selected values. Highlights when active. |
token |
A segmented chip with the label, a divider and the value. Shows +N for more values when you pass selectionDescription. |
States
Token states
active highlights a token that has an applied value. Without a value, it shows only the filter name.
Reset inside the control
FilterReset adds a × at the end of any trigger. Name it for the filter: “Remover filtro Cliente”.
Examples
Add a filter
AddFilterMenu lists the filters that can be added. Disable an option that is not available now.
Column picker
The menu stays open while the operator toggles columns. Disable a required column, such as the one that names the row.
Groups of values
groups adds a checkbox that selects several values at once, such as “Em aberto”. Pass selectionDescription to show a tooltip with the full selection. The tooltip needs a TooltipProvider above it, which the apps already provide.
Token with your own editor
FilterTokenTrigger is only the button. Wrap it in a Popover or a dropdown with asChild and put your editor inside.
Reset button
Place ResetFiltersButton in a flex row with items-center gap-1. It renders a divider and a button as siblings. Show it only when a filter is applied.
Applied filter badges
FilterToolbar shows one badge per applied filter. Each badge opens the side sheet that holds the filter editors, so it must sit inside a Sheet.
Filter editors
Content
- Filter names are short nouns: “Status”, “Cliente”, “Prazo”, “Revisor”.
- Values show as written in the list: “Em revisão”, “Banco Aurora”. With many values, the token shows the first and
+N. - The menu to add filters says “Adicionar filtro”. The reset says “Limpar filtros”.
- Give every remove button a label with the filter name: “Remover filtro Status”.
Do and don’t
Accessibility
- Menus and popovers keep the Radix keyboard and focus behavior:
EnterorSpaceopens, arrows move,Escapecloses and focus returns to the trigger. ChoiceFiltergives its trigger an accessible name made of the label and the selection, such as “Status: Em revisão”. Items are checkboxes, so each one reports checked or not.- The reset × is a button with an
aria-labeland atitlefromremoveLabel. Always pass a label with the filter name. ColumnsControlis an icon-only button: passcolumnsLabel, which becomes itsaria-labelandtitle.- The × buttons are 24px, the minimum hit target.
- When a reset or a remove action hides its own button, move focus to a stable element, for example the next filter or the add menu.
- Menu text comes from props. Pass translated copy from the app.
Code
import { ChoiceFilter } from "@repo/ui/choice-filter";
<ChoiceFilter
label="Status"
onChange={setStatus}
onReset={() => setStatus([])}
options={[
{ label: "Pendente", value: "pendente" },
{ label: "Em revisão", value: "revisao" },
]}
removeLabel="Remover filtro Status"
values={status}
variant="token"
/>;
Props
ChoiceFilter| Prop | Type | Default | Description |
|---|---|---|---|
label | string | — | Filter name. Required. |
options | { label: string; value: string }[] | — | Choices. Required. |
values | string[] | — | Selected values. Required. |
onChange | (values: string[]) => void | — | Called with the new selection. Required. |
variant | "default" | "token" | "default" | Button or token look. |
active | boolean | values.length > 0 | Highlights the trigger. |
summary | string | — | Replaces the selected values shown on the trigger. |
selectionDescription | string | — | Text of the tooltip. In the token, also adds the `+N` counter. |
groups | { label: string; values: string[] }[] | [] | Checkboxes that select several values at once. |
onReset | () => void | — | Shows a × button that calls it. |
removeLabel | string | label | Accessible name of the × button. |
defaultOpen / onOpenChange | boolean / (open: boolean) => void | — | Open the menu at first render, and listen to it opening. |
children | ReactNode | — | Extra content at the top of the menu. |
FilterTokenTrigger| Prop | Type | Default | Description |
|---|---|---|---|
label | string | — | Filter name. Required. |
active | boolean | — | The filter has an applied value. Required. |
valueLabel | string | — | Selected value, cut when it is long. |
remainingCount | number | 0 | Shows `+N` after the first value. |
FilterTokenTrigger also takes the props of a Button, such as aria-label, disabled and onClick, and forwards the ref.
AddFilterMenu| Prop | Type | Default | Description |
|---|---|---|---|
label | string | — | Text of the trigger. Required. |
options | { name: string; label: string; disabled?: boolean }[] | — | Filters that can be added. Required. |
onAdd | (name: string) => void | — | Called with the chosen filter. Required. |
triggerRef / onCloseAutoFocus | Ref / (event: Event) => void | — | Send focus to the editor that opens after adding. |
ColumnsControl| Prop | Type | Default | Description |
|---|---|---|---|
columns | { id: string; label: string; checked: boolean; disabled: boolean }[] | — | Resolved state of each column. Required. |
onToggle | (id: string, visible: boolean) => void | — | Applies one change. Required. |
onReset | () => void | — | Adds a reset item to the menu. |
columnsLabel / resetLabel / emptyLabel | string | — | Translated copy: the button name, the reset item and the message when there are no columns. |
ResetFiltersButton| Prop | Type | Default | Description |
|---|---|---|---|
label | string | — | Visible text. Required. |
onReset | () => void | — | Clears or restores the filters. Required. |
title | string | — | Longer description on hover. |
FilterReset| Prop | Type | Default | Description |
|---|---|---|---|
removeLabel | string | — | Accessible name of the × button. Required. |
onReset | () => void | — | Shows the × button when set. |
placement | "inside" | "after" | "inside" | The × sits inside the trigger, or after it. |
FilterToolbar| Prop | Type | Default | Description |
|---|---|---|---|
filters | FilterConfig[] | — | One badge per entry with `visible: true`. Each has `name`, `label`, `value`, `selectedValues`, `leftIcon`, `onClear` and `visible`. |
Known issues
| Issue | Effect |
|---|---|
ChoiceFilter defaults removeLabel to label. |
If the app does not pass it, the × button is read as “Status”, not as a remove action. |
FilterToolbar hardcodes Remover filtro ${label} as the aria-label of the × button. |
The text cannot be translated by the app. |
FilterToolbar badges use bg-warning with text-warning/80 and hover:bg-brand-light/50, and capitalize on the label. |
A translucent text color, and labels that are forced to capitalized case. |
FilterToolbar uses SheetTrigger and needs a parent Sheet. |
Rendering it alone throws an error from Radix. |
SelectFilter has hardcoded copy: “Selecionar…”, “Buscar {label}…” and “Nenhuma opção encontrada.”. MultiSelectFilter defaults its placeholder to “Selecionar opções…”. |
The empty message cannot be changed from props, and the package is not i18n-free. |
SelectFilter dims its icon with opacity-60. |
A translucent fill, against the repository rule of solid colors. |
DateRangeFilter accepts placeholder, presets and showPresets but ignores them. |
Props that look usable do nothing. The values come from DateRangeLocaleProvider. |