Introduction
Installation
Next.jsViteLaravelReact RouterRemixAstroTanStack StartTanStack RouterManual InstallationMCP
All componentsTheme
FieldFormInputText FieldTextareaSearch FieldInput OTPNumber FieldNumber FormatSliderCheckboxSwitchRadioSelectCombo BoxList BoxChoice BoxMulti SelectToken FieldNewTag FieldTag GroupCalendarDate FieldDate PickerDate Range PickerRange CalendarTime FieldColor PickerColor FieldColor AreaColor SliderColor SwatchColor Swatch PickerColor ThumbColor WheelDrop ZoneFile Trigger
ButtonButton GroupToggleToggle GroupPreskok Auth Button
EditorHeadingLinkTextKeyboard
CardContainerGrid ListResizableTableFilter BarNewTreeSeparatorDescription ListScroll AreaShow MoreToolbar
BreadcrumbsNavbarPaginationTabsSidebar
DialogModalDrawerPopoverPreview TriggerNewSheetTooltipContext MenuDropdownCommandCommand MenuDisclosureMenu
ToastProgress BarProgress CircleMeterLoaderSkeletonNoteBadge
ChartArea ChartBar ChartLine ChartPie ChartRadial ChartRadar ChartBar ListTrackerRecharts ChartsDeprecated
Async ImageAvatarCarouselPreskok Icon
Layout

Filter Bar

Filter a list with chips that read like a sentence, added from a searchable menu.

View as MarkdownAsk ChatGPT

Installation

npx shadcn@latest add @preskok/filter-bar

Usage

import { useState } from "react"

import {
  FilterBar,
  FilterBarAdd,
  FilterBarChips,
  FilterBarClear,
  matchesFilter,
  type Filter,
  type FilterField,
} from "@/components/ui/preskok-ui/filter-bar"

const fields: Array<FilterField> = [
  {
    id: "status",
    label: "Status",
    variant: "select",
    options: [
      { value: "available", label: "Available" },
      { value: "sold", label: "Sold" },
    ],
  },
  { id: "price", label: "Price", variant: "number", unit: "€" },
]

const vehicles = [
  { id: 1, name: "Volkswagen Golf", status: "available", price: 24900 },
  { id: 2, name: "Tesla Model 3", status: "sold", price: 39500 },
]

export function Vehicles() {
  const [filters, setFilters] = useState<Array<Filter>>([])
  const rows = vehicles.filter((vehicle) =>
    filters.every((filter) =>
      matchesFilter(
        filter.field === "price" ? vehicle.price : vehicle.status,
        filter
      )
    )
  )

  return (
    <>
      <FilterBar fields={fields} value={filters} onChange={setFilters}>
        <FilterBarChips />
        <FilterBarAdd />
        <FilterBarClear />
      </FilterBar>
      <ul>
        {rows.map((vehicle) => (
          <li key={vehicle.id}>{vehicle.name}</li>
        ))}
      </ul>
    </>
  )
}

FilterBar holds the filters and lays its children out in a wrapping row, so a search field or a sort button can sit beside the chips. A filter is plain data, { field, operator, value } with a tagged value such as { type: "range", min: 10000, max: 25000 }, so it goes into a URL or a request body as it is. "+ Filter" adds the filter as soon as a field is picked and drops it if the popover closes without a value, so use isFilterActive to skip filters that narrow nothing yet.

Fields and operators

A field's variant sets its operators and value editor. The first operator is the default; pass operators to restrict or reorder them.

VariantOperatorsValue type
textcontains, notContains, is, isNot, isEmpty, isNotEmptytext (text)
numberbetween, is, isNot, lt, lte, gt, gte, isEmpty, isNotEmptyrange (min, max) or number
selectisAnyOf, isNoneOf, isEmpty, isNotEmptyoptions (values)
booleanisboolean (value)
datebetween, is, before, after, isEmpty, isNotEmptydays (start, end) or day

isEmpty and isNotEmpty carry { type: "none" }.

Examples

Basic

The bar keeps its own filters from defaultValue. A select with multiple: false closes on the first pick.

Custom chips

FilterBarChips renders <FilterChip /> for each filter. Pass a function to build chips from FilterChipField, FilterChipOperator, FilterChipValue and FilterChipRemove.

Translations

Pass messages for the strings; anything left out stays English. Numbers and dates follow the I18nProvider locale.

Server filtering

Send the active filters with the request instead of filtering rows in the browser.

Keyboard

<FilterBarAdd shortcut="f" /> opens "+ Filter" with F when no text field is focused. In a value editor, Enter applies the value and closes it.

Table

A comprehensive table component with sorting, resizing, and selection.

Tree

A tree component for hierarchical data display.

On this page

Installation
Usage
Fields and operators
Examples
Basic
Custom chips
Translations
Server filtering
Keyboard
Status
Vehicle
Year
Price
Mileage
Status
Listed
Volkswagen Golf2023€24,90012,400 kmavailableNov 18, 2026
Tesla Model 32024€39,5008,100 kmreservedNov 2, 2026
BMW i42023€47,80021,000 kmavailableOct 12, 2026
Renault Zoe2022€15,90031,700 kmavailableNov 15, 2026
Audi A4 Avant2022€33,40041,900 kmavailableSep 21, 2026
Volkswagen ID.42024€41,2002,300 kmreservedNov 19, 2026
Status
Status
Priority
Assignee