Loading component…
Loading component…
Grouped filters with removable chips, collapsible checkbox groups, Clear all and full keyboard control
To reuse this local React demo, copy all files from the Code tab into the same folder, then import FilterMenu from ./filter-menu.
import { FilterMenu } from "@/components/ui/filter-menu";
const groups = [
{ id: "stage", label: "Stage", options: [{ id: "new", label: "New lead" }, { id: "won", label: "Won" }] },
{ id: "size", label: "Deal size", chipPrefix: "Deal: ", options: [{ id: "s", label: "Under $5k" }, { id: "l", label: "Over $50k" }] },
];
export function DealFilters() {
const [filters, setFilters] = useState({});
return <FilterMenu groups={groups} value={filters} onChange={setFilters} />;
}| Name | Type | Default | Description |
|---|---|---|---|
| groups | FilterGroup[] | Required. Each { id, label, options: { id, label }[], chipPrefix? } | |
| value | Record<string, string[]> | Picked option ids per group – makes it controlled | |
| defaultValue | Record<string, string[]> | {} | Starting filters when uncontrolled |
| onChange | (value) => void | Called with the new filters after every change | |
| defaultOpen | string[] | the first group | Groups that start open |
| title | string | "Filters" | Heading on top |
| hints | boolean | true | Shows the keyboard hints on the tray |
| className | string | Extra class on the root |
Fills its container up to 420px wide; chips wrap onto new lines
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"
@import "tailwindcss"; in your main CSS file.