Skip to content
Klarhimmel UI

Filter bar

App, filter bar previewApp, filter bar preview

Install

npx shadcn add @klarhimmel/app-data-filters
DetailsAbout, usage, props and more

A search box and select filters above a list, active filters as removable chips with a clear-all, and a result count read from a list (one entry per filter removed) and…

States

filter bar in 3 forms: no filters on, filters on, no results.

  • no filters on

  • filters on

  • no results

Notes

When to use it

A search box and select filters above a list, with active filters as removable chips. For moving between pages of results use app-data-pagination; the table itself is app-data-table.

Writing for it

- title (60) is not shown. It names the search landmark for screen readers, so write what is being searched, such as Bookings. - Each select needs a label and 2 to 8 options of 30 characters, plus a sample for the value shown. Use up to 3 selects before the row gets crowded. - results is a list of count phrases, one per filter removed, such as 31 bookings. The block holds no data, so you write each number yourself.

Watch out for

The block filters nothing. Removing a chip only advances the count text, and removing more chips than there are results entries keeps the last one. Pass the host's list to the table separately.

Usage

The block in a page, with its default content (long lists shortened). Every prop is in the table below.

section.tsx
import { Theme } from '@/components/klarhimmel/theme/style';
import { BlockSurface } from '@/components/klarhimmel/blocks/surface';
import AppDataFilters from '@/components/klarhimmel/blocks/app-data-filters';

export default function Section() {
  return (
    <Theme theme="brand">
      <BlockSurface>
        <AppDataFilters props={{
          "title": "Name what is filtered",
          "searchLabel": "Name what to search",
          "sample": "",
          "selects": [
            {
              "label": "First filter",
              "options": [
                "All of the first",
                "Name option one",
                "Name option two",
                "Name option three"
              ],
              "sample": "Name option one"
            },
            {
              "label": "Second filter",
              "options": [
                "Any of the second",
                "Name option one",
                "Name option two",
                "Name option three"
              ],
              "sample": "Name option one"
            }
          ],
          "chips": [
            "First option",
            "Second option",
            "Third option"
          ],
          "removeLabel": "Remove filter",
          "clear": "Clear all",
          "results": [
            "00 results",
            "00 results",
            "00 results",
            "000 results"
          ]
        }} />
      </BlockSurface>
    </Theme>
  );
}

Props

The type, default and text limit of every prop. On a real page, over-limit text is kept and checkSections flags it (Installation, Check a page before you ship); this live preview shows the default until it fits. The panel above edits all props.

PropTypeDefaultDescription
titlestring'Name what is filtered'Text, up to 60 characters.
searchLabelstring'Name what to search'Text, up to 40 characters.
samplestring''Text, up to 60 characters.
selects{ label, options, sample }[]2 itemsList of 1 to 3. Each item: label, options, sample.
chipsstring[]3 itemsList of up to 5.
removeLabelstring'Remove filter'Text, up to 30 characters.
clearstring'Clear all'Text, up to 30 characters.
resultsstring[]4 itemsList of 1 to 6.

Install

Installs

app-data-filters
Uses
  • Input
  • NativeSelect
  • Button
About
A search box and select filters above a list, active filters as removable chips with a clear-all, and a result count read from a list (one entry per filter removed) and announced politely. Focus moves on when a chip goes.
States
Search, selects and removable chips. A chip leaves when removed; Clear all removes the rest; the count is a live status. New project? Set it up once: /get-started/installation.