Builtwell

Category filter

Pick block categories as chips, each labelled with its count. A multiple combobox with its labels and sorting built in.

packages/design-system/components/combobox/category-filter.tsx

Examples

Two picked
Empty

Anatomy

  1. 01Chips row, the anchor
  2. 02Chip per pick, with remove
  3. 03Input
  4. 04Popup list

Usage

import { CategoryFilter } from "@repo/design-system/components/combobox/category-filter";

<CategoryFilter
  categories={[{ name: "header", totalBlocks: 14 }, { name: "footer", totalBlocks: 5 }]}
  selectedCategories={selected}
  onCategoriesChange={setSelected}
/>

Props

PropTypeDefaultDescription
categories*{ name: string; totalBlocks: number }[]noneShown capitalised with the count, as "Header (14)", sorted by name.
selectedCategories*string[]noneThe picked names.
onCategoriesChange*(categories: string[]) => voidnoneCalled with the new list.
placeholderstring"Search categories..."Once something is picked. Empty, it reads Select categories.
classNamestringnoneOn the wrapping div.

Guidance

Do

  • Use it where people filter a long list by several categories at once.

Don't

  • Use it for a single choice. Use a select or combobox.