affectUI › Components › Inputs

Filter Menu

Grouped filters with removable chips, collapsible checkbox groups, Clear all and full keyboard control.

Free and open source (MIT). Install: npx shadcn@latest add https://www.affectui.com/r/filter-menu.json · Import from @/components/ui/filter-menu

When to use

  • Filtering a list, table or board by a few groups of options – stage, owner, region and the like
  • Side panels or popovers where people pick several filters and want to see them all at a glance

When not to use

  • A single choice from a short list – use a select or segmented control
  • Free-text search or numeric ranges with a slider – this menu works with predefined options

Usage

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} />;
}

Props

NameTypeDefaultDescription
groupsFilterGroup[]Required. Each { id, label, options: { id, label }[], chipPrefix? }
valueRecord<string, string[]>Picked option ids per group – makes it controlled
defaultValueRecord<string, string[]>{}Starting filters when uncontrolled
onChange(value) => voidCalled with the new filters after every change
defaultOpenstring[]the first groupGroups that start open
titlestring"Filters"Heading on top
hintsbooleantrueShows the keyboard hints on the tray
classNamestringExtra class on the root

Keyboard

  • ↑ / ↓: Moves through group headers and the options of open groups
  • Enter / Space: Picks or unpicks an option, or opens and closes a group
  • → / ←: Opens a group, or closes it and jumps back to its header
  • Home / End: Jumps to the first or last row

Accessibility

  • Group headers are buttons with aria-expanded; options are role=checkbox with aria-checked
  • One roving tab stop for the list, so Tab moves past it in one step
  • Each chip has a remove button labelled with the filter; changes to the chips are announced politely

Responsive

  • 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"

Requirements

  • React 19