Shadcn React Table

Search documentation

Search the docs

Advanced filter

Set enableAdvancedFilter: true to add a toolbar button that opens a dialog where users build compound filter rules — multiple conditions joined by All (AND) or Any (OR) logic. The button badges the number of active rules.

Advanced filter
GitHub
ID
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
const table = useDataTable({
  data,
  columns,
  getRowId: (row) => row.id,
  enableAdvancedFilter: true,
})

return <DataTable table={table} />

How it works

Each rule is a { columnId, operator, value }. The available operators adapt to the column's meta.variant:

VariantOperators
text (default)contains, does not contain, starts with, ends with, equals, not equals, is empty, is not empty
select / multi-selectequals, not equals, is empty, is not empty
range / range-sliderequals, not equals, >, , <, , between, is empty, is not empty
date / date-rangeequals, not equals, >, <, between, is empty, is not empty
checkboxequals

Build your rules in the dialog, then click Apply to filter the table. Closing or cancelling the dialog discards unapplied edits.

Additive to column filters

The advanced filter is independent of the per-column filter row and global search: a row must pass all active filter systems to be shown. Clear the panel's rules (or use "Clear all") to remove just the advanced filters.

Controlled usage

Drive the filter from your own state with advancedFilter + onAdvancedFilterChange (or seed an uncontrolled table with defaultAdvancedFilter).

const [filter, setFilter] = React.useState<AdvancedFilterGroup>({
  logic: "and",
  rules: [],
})

const table = useDataTable({
  data,
  columns,
  enableAdvancedFilter: true,
  advancedFilter: filter,
  onAdvancedFilterChange: setFilter,
})