Shadcn React Table

Search documentation

Search the docs

Global search

An expandable global search box appears in the toolbar by default (enableGlobalFilter: true). It filters across all searchable columns at once, complementing the per-column filters.

Global search
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

Search modes

When enableGlobalFilterModes: true (the default), the search box shows a mode menu — fuzzy, contains, and more. The initial mode comes from defaultGlobalFilterMode, which defaults to "fuzzy".

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

const table = useDataTable({
  data,
  columns,
  getRowId: (row) => row.id,
  enableGlobalFilter: true,
  enableGlobalFilterModes: true,
  defaultGlobalFilterMode: "fuzzy",
})
return <DataTable table={table} />

Set enableGlobalFilter: false to remove the search box from the toolbar.

const table = useDataTable({
  data,
  columns,
  getRowId: (row) => row.id,
  enableGlobalFilter: false,
})

Custom mode menu

Replace the built-in mode radio items with renderGlobalFilterModeMenuItems. It receives the allowed modes, the currentMode, and an onSelect(mode) to switch.

import { DropdownMenuItem } from "@/components/ui/dropdown-menu"

useDataTable({
  renderGlobalFilterModeMenuItems: ({ modes, currentMode, onSelect }) =>
    modes.map((mode) => (
      <DropdownMenuItem
        key={mode}
        disabled={mode === currentMode}
        onClick={() => onSelect(mode)}
      >
        {mode}
      </DropdownMenuItem>
    )),
})

Ranked results

In fuzzy mode, each match carries a relevance score. Set enableGlobalFilterRankedResults to order rows by that score — best matches first — for as long as a search is active.

const table = useDataTable({
  data,
  columns,
  getRowId: (row) => row.id,
  defaultGlobalFilterMode: "fuzzy",
  enableGlobalFilterRankedResults: true,
})

The ranking yields to the user: the moment they click a column to sort, their sort takes over, and clearing the search restores the original order. It applies only in "fuzzy" mode and is skipped while grouping or row expansion is active, or under manualSorting / manualFiltering (the server owns ordering there).

Off by default

Material React Table enables this by default; the data table keeps it off so adding a search box never silently reorders your rows. Opt in when relevance ordering is what you want.

Placement

Move the search to the left toolbar region with positionGlobalFilter: "left" — see Toolbar customization.

Relevant options

PropTypeDefaultDescription
enableGlobalFilter?booleantrueShow the expandable global search in the toolbar. Default true.
enableGlobalFilterModes?booleantrueShow the global search mode menu (fuzzy/contains/…). Default true.
defaultGlobalFilterMode?GlobalFilterMode"fuzzy"Initial global search mode. Default "fuzzy".
enableGlobalFilterRankedResults?booleanfalseWhile the global search is in fuzzy mode, order rows by best match (most relevant first) until the user applies their own sort. Default false — MRT defaults this on, but the data table keeps it off so searching never silently reorders rows unless opted in. Ignored for non-fuzzy modes, when grouping or expanded, or under manual sorting/filtering.
globalFilterMode?GlobalFilterModeControlled global search mode. Pair with `onGlobalFilterModeChange`; omit for uncontrolled (seed with `defaultGlobalFilterMode`).
onGlobalFilterModeChange?(mode: GlobalFilterMode) => voidCalled whenever the global search mode changes.
positionGlobalFilter?"left" | "right" | "none""right"Which toolbar region the global search renders in. Default "right" (the internal-actions cluster). "left" places it next to the title/actions; "none" hides it (same as `enableGlobalFilter: false`).