Filter chips Free
Free forever. One command, source you own.
Install
npx shadcn@latest add https://cottoncandy.dev/r/filter-chips.jsonFree. Lands in components/mu/filter-chips/ with the shared foundation. Needs React 19, Tailwind v4 and motion; reads your shadcn theme, and dark mode follows .dark.
Usage
import { FilterChips } from "@/components/mu/filter-chips/FilterChips";
<FilterChips filters={filters} onFiltersChange={setFilters} onAdd={openPicker} count={total} />Use with an agent Beta
npx shadcn@latest add https://cottoncandy.dev/r/uisdk/filter-chips.jsonOptional. An AI agent in your app can read and set this piece by name, and you can ask before anything it can’t undo. The piece itself doesn’t change. Built on UI SDK 0.1.0-beta.23, which is in beta too, so this add-on follows its releases.
Source
How it works
Building with an agent? Hand it a ready prompt for this piece.
Input and reduced motion
- Pointer / touch: press "+ Filter" to add (your picker), press a chip to remove it. When they are merged, press the pill to see them, remove any, add, or clear all.
- Keyboard: Tab walks the pill and the chips; Enter or Space removes a chip and focus returns to the pill. The merged pill opens its list with Enter and Escape closes it, back to the pill. The count is read out through a polite status region.
- Reduced motion: no bud or merge travel: chips appear and leave at their place, the count's digits land at once, and the merge is a quick swap.
Props
| Prop | Default | What it does |
|---|---|---|
filters | — | Filter[] ({ id, label, value }) | the filters on, in order; a chip reads "label: value" |
defaultFilters | [] | Filter[] | the filters on at first, when it keeps its own |
onFiltersChange | — | (filters) => void | a chip removed, or all cleared |
onAdd | — | (pill) => void | "+ Filter" was pressed: open your picker by the pill it hands you, then add to filters |
count | hidden | number or null | how many results match; null says "Counting…" |
name | — | string | posts the filters as JSON in a form |
labels | see below | object | add ("Filter"), results ("{count} results"), counting ("Counting…"), merged ("{n} filters"), remove ("Remove {filter}"), clear ("Clear all") |
locale | the visitor's | BCP 47 | number format for the count |
sound | off | true or 0–1 | a soft key when a chip is removed |
className | — | — | added to the root |
Sound
None. It loads in silence.
Off unless you pass sound (true, or a volume 0–1). Removing a chip or clearing all plays a soft key. It never plays on hover, on mount, or when filters or count change from outside. setMuted(true) from components/mu/sounds.ts silences every cottoncandy item at once.
Licence
Free to use in your projects, under the terms on the licence.
Filters bud off a '+ Filter' pill as chips and the result count rolls to match; when space runs short they merge into one pill.
For search filters and result listsMore in Controls & forms