Skip to content
Klarhimmel UI

Collection controls

Filters & sort
npx shadcn add @klarhimmel/collection-controls
DetailsAbout, usage, props and more

Native search, filter and sort controls that collapse their options in narrow containers.

Preview

Filters & sort
Topics
collection-controls.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { CollectionControls } from '@/components/klarhimmel/ui/collection-controls';

export default function Example() {
  return (
    <Theme theme="brand">
      <CollectionControls search={{ name: "q", label: "Search articles", placeholder: "Find an article…" }} sort={{ name: "sort", label: "Sort by", options: [{ value: "newest", label: "Newest first" }] }} />
    </Theme>
  );
}

Import

Import

import { CollectionControls } from '@/components/klarhimmel/ui/collection-controls';
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

PropTypeDefaultDescription
search{ name: string; label: string; placeholder?: string; inputProps?:…requiredA named native search input, always visible.
choices{ name: string; label: string; options: CollectionOption[]; defaultValue:…-Optional radio choices with counts.
filtersCollectionSelect[][]Named native selects with labels and options.
sortCollectionSelect-Named native selects with labels and options.
disabledbooleanfalseKeep controls disabled until the application’s filtering is ready.
disclosureLabelstring'Filters & sort'Disclosure and reset labels. Empty resetLabel omits the reset button.
resetLabelstring'Clear filters'Disclosure and reset labels. Empty resetLabel omits the reset button.
native attributesFormHTMLAttributes-Every native attribute of the element passes through, className included.