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.
ID | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Ava | Thompson | Owner | Engineering | active | 22 | $45,000 | Jan 2, 2023 | 0% | ||
| Liam | Nguyen | Admin | Marketing | inactive | 25 | $47,137 | Jan 13, 2023 | 9% | ||
| Noah | Silva | Editor | Design | pending | 28 | $49,274 | Jan 24, 2023 | 18% | ||
| Emma | Carter | Viewer | Sales | active | 31 | $51,411 | Feb 4, 2023 | 27% | ||
| Olivia | Rossi | Owner | Support | inactive | 34 | $53,548 | Feb 15, 2023 | 36% | ||
| William | Walker | Admin | Engineering | pending | 37 | $55,685 | Feb 26, 2023 | 45% | ||
| Sophia | Patel | Editor | Marketing | active | 40 | $57,822 | Mar 9, 2023 | 54% | ||
| James | Muller | Viewer | Design | inactive | 43 | $59,959 | Mar 20, 2023 | 63% | ||
| Isabella | Park | Owner | Sales | pending | 46 | $62,096 | Mar 31, 2023 | 72% | ||
| Lucas | Reyes | Admin | Support | active | 49 | $64,233 | Apr 11, 2023 | 81% | ||
| $4,120,536 |
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} />
Disabling global search
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
| Prop | Type | Default | Description |
|---|---|---|---|
enableGlobalFilter? | boolean | true | Show the expandable global search in the toolbar. Default true. |
enableGlobalFilterModes? | boolean | true | Show the global search mode menu (fuzzy/contains/…). Default true. |
defaultGlobalFilterMode? | GlobalFilterMode | "fuzzy" | Initial global search mode. Default "fuzzy". |
enableGlobalFilterRankedResults? | boolean | false | While 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? | GlobalFilterMode | — | Controlled global search mode. Pair with `onGlobalFilterModeChange`; omit for uncontrolled (seed with `defaultGlobalFilterMode`). |
onGlobalFilterModeChange? | (mode: GlobalFilterMode) => void | — | Called 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`). |