Filter Button
FilterButton is a compact multi-select trigger that opens a checklist in a popup.
import { FilterButton } from '@/components/ui/wideset/filter-button/FilterButton';
<FilterButton
options={[
{ value: 'active', label: 'Active' },
{ value: 'paused', label: 'Paused' },
{ value: 'archived', label: 'Archived' },
]}
label="Status"
placeholder="Status"
defaultValue={['active']}
onChange={(statuses) => console.log(statuses)}
/>Installation
pnpm dlx wideset add filter-button
Copies the component and any Wideset components it uses into your project.
Examples
Sizes
Small fits compact toolbars and table headers, medium is the usual choice in a filter bar, and large gives the trigger more weight and a bigger hit area. Use one size for every filter in a row, matching the inputs and buttons next to it.
import { FilterButton } from '@/components/ui/wideset/filter-button/FilterButton';
const statuses = [
{ value: 'active', label: 'Active' },
{ value: 'paused', label: 'Paused' },
{ value: 'archived', label: 'Archived' },
];
export default function FilterButtonSizes() {
return (
<div className="gap-ws-10 flex flex-wrap items-center">
{(['sm', 'md', 'lg'] as const).map((size) => (
<FilterButton
key={size}
size={size}
options={statuses}
label="Status"
placeholder="Status"
onChange={(selected) => console.log(selected)}
/>
))}
</div>
);
}States
With nothing chosen the trigger shows its placeholder. Once options are chosen it keeps the label and summarises the selection ("Active, +1"), and a clear button resets it in one click. Disabled keeps the current selection visible but blocks opening the list and clearing it; use it only while filtering is briefly unavailable, such as during a reload.
import { FilterButton } from '@/components/ui/wideset/filter-button/FilterButton';
const statuses = [
{ value: 'active', label: 'Active' },
{ value: 'paused', label: 'Paused' },
{ value: 'archived', label: 'Archived' },
];
export default function FilterButtonStates() {
return (
<div className="gap-ws-10 flex flex-wrap items-center">
<FilterButton
options={statuses}
label="Status"
placeholder="Status"
onChange={(selected) => console.log(selected)}
/>
<FilterButton
options={statuses}
label="Status"
placeholder="Status"
defaultValue={['active', 'paused']}
onChange={(selected) => console.log(selected)}
/>
<FilterButton
options={statuses}
label="Status"
placeholder="Status"
defaultValue={['active', 'paused']}
onChange={(selected) => console.log(selected)}
disabled
/>
</div>
);
}API reference
| Name | Description | Default |
|---|---|---|
onChange* | Called with the full array of selected option values whenever selection changes. (value: string[]) => void | — |
options* | Available options rendered inside the filter popover. FilterButtonOption[] | — |
clearFilterAriaLabel | Accessible label for the clear-filter button. Defaults to `'Clear filter'`. string | 'Clear filter' |
defaultMotion | Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`. boolean | true |
defaultValue | Initial selected option values in uncontrolled mode. (string[] & (string | number | readonly string[])) | — |
disabled | boolean | false |
label | Prefix label shown before the selected-value summary. string | 'Filter' |
placeholder | Placeholder shown in the trigger when no options are selected. string | 'Filter' |
selected | boolean | false |
size | 'sm''md''lg' | 'sm' |
value | Controlled array of selected option values. (string[] & (string | number | readonly string[])) | — |
<button> is passed through to it. See MDN: <button>.Accessibility
- The list is a
listboxwitharia-multiselectable; arrow keys move, Enter or Space toggles. - Set
clearFilterAriaLabelto name the dimension when several filters sit in one row (“Clear status filter”), or every clear button reads “Clear filter”.
import { FilterButton } from '@/components/ui/wideset/filter-button/FilterButton';
<FilterButton
options={[
{ value: 'active', label: 'Active' },
{ value: 'paused', label: 'Paused' },
{ value: 'archived', label: 'Archived' },
]}
label="Status"
placeholder="Status"
defaultValue={['active']}
onChange={(statuses) => console.log(statuses)}
/>