Collection controls
npx shadcn add @klarhimmel/collection-controlsCopy for AIDetailsAbout, usage, props and more
Native search, filter and sort controls that collapse their options in narrow containers.
Preview
Import
Import
- Files
- collection-controls.tsx, collection-controls.css, in components/klarhimmel/ui/. With it: input, native-select, theme, utils. npm: lucide-react.
- Render in
- Render it inside <Theme>, once near the root of your app. Tokens and fonts are scoped to it, so outside it the component is unstyled.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
search | { name: string; label: string; placeholder?: string; inputProps?:… | required | A named native search input, always visible. |
choices | { name: string; label: string; options: CollectionOption[]; defaultValue:… | - | Optional radio choices with counts. |
filters | CollectionSelect[] | [] | Named native selects with labels and options. |
sort | CollectionSelect | - | Named native selects with labels and options. |
disabled | boolean | false | Keep controls disabled until the application’s filtering is ready. |
disclosureLabel | string | 'Filters & sort' | Disclosure and reset labels. Empty resetLabel omits the reset button. |
resetLabel | string | 'Clear filters' | Disclosure and reset labels. Empty resetLabel omits the reset button. |
native attributes | FormHTMLAttributes | - | Every native attribute of the element passes through, className included. |