Shadcn React Table

Search documentation

Search the docs

Column filtering

Each column can expose its own filter control in a per-column filter row. Toggle the row with the funnel icon in the toolbar, or have it open from the start with initialState: { showColumnFilters: true }.

Column filtersPer-column filter row with text, select, multi-select, range, and date variants.
GitHub
ID
2261
45000134754
099
AvaThompsonOwnerEngineeringactive22$45,000Jan 2, 2023
0%
LiamNguyenAdminMarketinginactive25$47,137Jan 13, 2023
9%
NoahSilvaEditorDesignpending28$49,274Jan 24, 2023
18%
EmmaCarterViewerSalesactive31$51,411Feb 4, 2023
27%
OliviaRossiOwnerSupportinactive34$53,548Feb 15, 2023
36%
WilliamWalkerAdminEngineeringpending37$55,685Feb 26, 2023
45%
SophiaPatelEditorMarketingactive40$57,822Mar 9, 2023
54%
JamesMullerViewerDesigninactive43$59,959Mar 20, 2023
63%
IsabellaParkOwnerSalespending46$62,096Mar 31, 2023
72%
LucasReyesAdminSupportactive49$64,233Apr 11, 2023
81%
$4,120,536
Rows per page
1–10 of 48

The filter-mode menu and a clear button sit inside the input. The menu leads and the clear button shows while there is a value. Range filters have one clear button per side. Dropdown, checkbox and slider filters keep the menu beside the control.

Choosing a filter control

The UI for each filter is chosen by the column's meta.filterVariant:

VariantControlValues
"text" (default)Text boxAny
"autocomplete"Text box suggesting the column's valuesAny
"select" / "multi-select"Dropdown / checklistStrings
"checkbox"CheckboxBooleans
"range" / "range-slider"Number boxes / sliderNumbers
"date" / "date-range"CalendarDates, compared by day
"datetime" / "datetime-range"Date-time boxDates, compared to the minute
"time" / "time-range"Time box"HH:mm" strings or Dates, compared by time of day

The date, date-time and time variants share the same modes (equals, before, after, between, empty…); the -range variants start in "between".

For select, multi-select and autocomplete, supply meta.filterSelectOptions as an array of { label, value }. If you omit them, the options are derived from the column's faceted unique values.

tsx
import { DataTable, useDataTable } from "@/components/ui/data-table"

const columns = [
  { accessorKey: "title", header: "Title", meta: { filterVariant: "text" } },
  {
    accessorKey: "status",
    header: "Status",
    meta: {
      filterVariant: "select",
      filterSelectOptions: [
        { label: "Active", value: "active" },
        { label: "Archived", value: "archived" },
      ],
    },
  },
  { accessorKey: "score", header: "Score", meta: { filterVariant: "range" } },
]

const table = useDataTable({ data, columns, getRowId: (row) => row.id })
return <DataTable table={table} />
Date-time, time & autocomplete filtersdatetime, time-range and autocomplete filter variants.
GitHub
–
Ava ThompsonBerlinJan 6, 2025, 6:00 AM06:00
Liam NguyenTokyoJan 7, 2025, 9:15 AM08:30
Noah SilvaAustinJan 8, 2025, 12:30 PM10:00
Emma CarterLyonJan 9, 2025, 3:45 PM12:30
Olivia RossiMilanJan 10, 2025, 6:00 AM14:00
William WalkerTorontoJan 6, 2025, 9:15 AM16:30
Sophia PatelOsloJan 7, 2025, 12:30 PM06:00
James MullerLisbonJan 8, 2025, 3:45 PM08:30
Isabella ParkBerlinJan 9, 2025, 6:00 AM10:00
Lucas ReyesTokyoJan 10, 2025, 9:15 AM12:30
Rows per page
1–10 of 24

Open the filter row by default

tsx
const table = useDataTable({
  data,
  columns,
  getRowId: (row) => row.id,
  initialState: { showColumnFilters: true },
})

Custom filter UI

Use meta.renderColumnFilter as an escape hatch to render your own filter control for a column.

Match highlighting

Matched substrings in cells are highlighted by default. Disable it for the whole table with enableFilterMatchHighlighting: false, or for a single column with meta.enableFilterMatchHighlighting: false.

A column with its own cell renderer gets the highlighted value as renderedCellValue (as in Material React Table). Render it where the value goes to keep the highlighting:

tsx
{
  accessorKey: "team",
  header: "Team",
  cell: ({ renderedCellValue }) => <Badge>{renderedCellValue}</Badge>,
}

Disabling a column's filter

Set enableColumnFilter: false on a column to remove its filter control entirely.

Faceted values

Select / multi-select filters auto-derive their options, and range filters their min/max bounds, from the data's faceted values. This is on by default; set enableFacetedValues: false to skip computing the faceted row models (e.g. for very large client-side datasets) — then provide meta.filterSelectOptions explicitly for select-style filters.

Faceted valuesFilter options, counts and slider bounds from the data.
GitHub
2261
AvaOwnerGermany22
LiamAdminJapan25
NoahEditorUSA28
EmmaViewerFrance31
OliviaOwnerItaly34
WilliamAdminCanada37
SophiaEditorNorway40
JamesViewerPortugal43
IsabellaOwnerGermany46
LucasAdminJapan49
Rows per page
1–10 of 48

Relevant options

useDataTable options that affect column filtering:

PropTypeDefaultDescription
onShowColumnFiltersChange?(showColumnFilters: boolean) => void—Called whenever the filter row is shown or hidden. Set it with `initialState.showColumnFilters`, control it with `state.showColumnFilters`.
enableColumnFilterModes?booleantrueShow the filter-mode menu adornment on filter fields. Default true.
enableFilterMatchHighlighting?booleantrueHighlight matched substrings in cells. Default true.
enableFacetedValues?booleantrueCompute faceted unique values / min-max (auto select options + range bounds). Default true; disable to skip the faceted row models.
columnFilterDisplayMode?ColumnFilterDisplayMode"subheader"Where column filter inputs live: `"subheader"` (a filter row under the header, default), `"popover"` (per-column popovers opened from the column header), or `"custom"` (you render them).

Per-column, via columnDef.meta:

meta keyTypeDescription
filterVariant?FilterVariantFilter UI variant rendered in the filter row. Defaults to "text".
filterSelectOptions?DataTableFilterOption[]Options for `select` / `multi-select` filter variants. If omitted for a select-style variant, options are derived from faceted unique values.
filterMode?FilterModeDefault filter mode for this column (overrides the per-variant default).
enableColumnFilterModes?booleanPer-column override for the filter-mode menu (defaults to the table).
renderColumnFilter?(props: { column: Column<TFeatures, TData, TValue> table: DataTableInstance<TData> }) => React.ReactNodeCustom filter UI for this column (escape hatch). Replaces the variant.
columnFilterModeOptions?FilterMode[]Restrict (and order) the filter-mode menu for this column to this subset of modes (built-in ones and custom `filterFns` names). Include the column's default mode.
enableFilterMatchHighlighting?boolean`false` opts this column out of match highlighting (the table option of the same name turns it on or off for every column).