DocsGuides

Guides

Filter Chips Guide

How the default filter chips, the column picker and the filter editor of Shadcn Table work, and how to switch to other filter display modes

By default, column filters live in the toolbar as chips: one chip per filtered column, showing the column's icon, its label and a summary of the value. There are no filter inputs under the headers. This is the 'chips' filter display mode, the default of the columnFilterDisplayMode table option.

Example

Relevant Table Options

Prop NameTypeDescription
columnFilterDisplayMode'chips' | 'custom' | 'popover' | 'subheader'Where column filters show. 'chips' (the default) puts one chip per filter in the toolbar; 'subheader' puts an input under each header; 'popover' opens the input from the header filter icon; 'custom' renders nothing so you can place the filters yourself.
enableColumnFilterModesbooleanShows the filter mode picker on every column filter. Set false to hide it; a column can turn it off with its own enableColumnFilterModes: false.
enableColumnFiltersboolean
enableFiltersbooleanEnable or disable both the global and column filters.
onColumnFiltersChangeOnChangeFn<ColumnFiltersState>If provided, this function will be called with an updaterFn when state.columnFilters changes. This overrides the default internal state management, so you will need to persist the state change either fully or partially outside of the table.

Relevant Column Options

Column OptionTypeDescription
columnFilterModeOptionsArray<string>
enableColumnFilterbooleanEnable or disable column filtering for this column. Filter will not be shown if disabled.
enableColumnFilterModesbooleanFilter modes are on by default; set false to hide the filter mode picker for this column.
filterVariant'text' | 'select' | 'multi-select' | 'range' | 'range-slider' | 'checkbox' | 'autocomplete' | 'date' | 'date-range' | 'datetime' | 'datetime-range' | 'time' | 'time-range'Specify whether the filter should be a text input or a select input, or other type of pre-built input.
iconComponentType<ST_IconProps> | ReactNodeAn icon component or element shown before the column label in the header, in the filter chips and in the column picker of the filter and sort editors. Nothing renders when it is unset.

Relevant State

State OptionTypeDescription
columnFiltersArray<{id: string, value: unknown}>an array of objects with id and value properties, representing the current filter values for each column
filterChips{ columnIds: string[]; openAnchor: 'chip' | 'header' | 'toolbar' | null; openColumnId: string | null }The filter chips shown in the toolbar, in the order they were added, and the column whose filter editor is open with where it is anchored. A chip exists before it has a value.

Add a Filter

There are three ways to start filtering a column, and all of them open the same value editor:

  • The filter button in the toolbar group (aria-label "Filter") opens a searchable "Filter by..." column list. Picking a column swaps the same popover to that column's value editor, with a "Back to columns" button at the top. The popover glides to its new size on the swap (at once with reduced motion).
  • "+ Filter", a small button in the chip row, opens the same column list. It shows while a filter chip or a sort exists.
  • Filter in a column menu opens the value editor in a popover anchored to that column's header cell. Closing it returns focus to the column's chevron.

Every entry point adds the column's chip to the chip row in the background and flashes it, so you can see where the filter went. Chips appear in the order they were added. A chip exists before it has a value: an empty value keeps the chip.

The Filter Editor

The editor shows the column name on its top line, the column's filter input (the same input its filterVariant renders in other modes) and "Remove filter". Clicking a chip opens the same editor on the chip.

When a column has filter modes (the default) and filter mode options, the top line also has a mode picker ("Name contains"), a dropdown of the filter modes with their symbols. "Is empty" and "is not empty" hide the value input and keep the filter active. The in-field mode button and the "Filter Mode" line of the other modes do not render in chips mode.

Remove Filters

  • "Remove filter" in a chip's editor clears that column's value and removes its chip.
  • "Clear filters", next to the chips, clears every filter value and removes every chip. It shows only while a chip exists.
  • "Delete all filters" at the bottom of the column list does the same.
  • "Clear filter" in a column menu, shown while the column has a value, clears the value and removes its chip.

Removing a filter also puts its filter mode back to the column's first mode option.

Chip Summaries

A chip reads like a sentence: the column label, the filter mode when one is picked, and the value, for example "Name contains: Jo", "Age: 20 to 40", "Email is empty", or just "Name" while the chip has no value. Ranges use the rangeSummary localization key ('{min} to {max}'), checkboxes yes and no, and date bounds beforeValue and afterValue.

A chip for a hidden column stays in the row. Its editor says "Show the column to edit this filter." instead of showing the input.

Filter Chips State

The filterChips state holds the chip order and the open editor: columnIds (the chips, in the order added), openColumnId and openAnchor ('chip', 'toolbar' or 'header', where the open editor is anchored). A column that gets a filter value from initialState, from state or from your own code joins the chip row on its own. Set filterChips in initialState to show empty chips on load.

const table = useShadcnTable({
  columns,
  data,
  initialState: {
    columnFilters: [{ id: 'state', value: 'Ohio' }], //shows a "State: Ohio" chip
    filterChips: {
      columnIds: ['state', 'city'], //the City chip shows too, with no value yet
      openAnchor: null,
      openColumnId: null,
    },
  },
});

Other Filter Display Modes

The chips are one of four columnFilterDisplayMode values. The filter functions, filter variants and filter inputs are the same in every mode.

  • 'chips' (default): chips in the toolbar, as described above
  • 'subheader': a filter input under each header, shown and hidden with the toolbar's filter toggle (showColumnFilters state)
  • 'popover': a filter icon in each header opens the input in a popover
  • 'custom': no built-in filter UI, so you can render your own
const table = useShadcnTable({
  columns,
  data,
  columnFilterDisplayMode: 'subheader', //filter inputs under the headers, as before v0.8
});

See the Column Filtering Guide for the filter variants and functions.

View Extra Storybook Examples

On this page