Column Filtering Feature Guide
Filtering is one of the most powerful features of Mantine React Table and is enabled by default. There is a lot of flexibility and customization available here. Whether you want to customize the powerful client-side filtering already built in or implement your own server-side filtering, Mantine React Table has got you covered.
Relevant Table Options
# | Prop Name | Type | Default Value | More Info Links | |
|---|---|---|---|---|---|
| 1 | 'subheader' | 'popover' | 'custom' | 'subheader' | MRT Column Filtering Docs | ||
| 2 | Array<MRT_FilterOption | string> | null | | MRT Column Filtering Docs | ||
| 3 | boolean | false | MRT Column Filtering Docs | ||
| 4 | boolean | true | MRT Column Filtering Docs | ||
| 5 | boolean | | MRT Column Filtering Docs | ||
| 6 | boolean | true | MRT Column Filtering Docs | ||
| 7 | boolean | true | TanStack Filters Docs | ||
| 8 | Record<string, FilterFn> | | TanStack Table Filters Docs | ||
| 9 | boolean | false | TanStack Filtering Docs | ||
| 10 | () => Map<any, number> | | TanStack Table Filters Docs | ||
| 11 | () => RowModel<TData> | | TanStack Table Filters Docs | ||
| 12 | () => Map<any, number> | | TanStack Table Filters Docs | ||
| 13 | () => RowModel<TData> | | TanStack Table Filters Docs | ||
| 14 | AutocompleteProps | ({ column, table, rangeFilterIndex }) => AutocompleteProps | | Mantine Autocomplete Docs | ||
| 15 | CheckboxProps | ({ column, table }) => CheckboxProps | | Mantine Checkbox Docs | ||
| 16 | DateInputProps | ({ table, column, rangeFilterIndex }) => DateInputProps | | Mantine DateInput Docs | ||
| 17 | MultiSelectProps | ({ column, table }) => MultiSelectProps | { clearable: true } | Mantine MultiSelect Docs | ||
| 18 | SelectProps | ({ column, table }) => SelectProps | | Mantine Select Docs | ||
| 19 | TextInputProps | ({ table, column, rangeFilterIndex }) => TextInputProps | | Mantine TextInput Docs | ||
| 20 | HighlightProps | ({ cell, column, row, table }) => HighlightProps | | Mantine Highlight Docs | ||
| 21 | boolean | | TanStack Table Filters Docs | ||
| 22 | number | 100 | TanStack Table Filtering Docs | ||
| 23 | OnChangeFn<{ [key: string]: MRT_FilterOption }> | | |||
| 24 | OnChangeFn<ColumnFiltersState> | | TanStack Table Filter Docs | ||
| 25 | OnChangeFn<boolean> | | |||
| 26 | ({ column, internalFilterOptions, onSelectFilterMode, table }) => ReactNode | | |||
Relevant Column Options
# | Column Option | Type | Default Value | More Info Links | |
|---|---|---|---|---|---|
| 1 | Array<string> | | |||
| 2 | boolean | | MRT Column Filtering Docs | ||
| 3 | boolean | | MRT Column Filtering Docs | ||
| 4 | ({ column, header, table }) => ReactNode | | MRT Column Filtering Docs | ||
| 5 | MRT_FilterFn | 'fuzzy' | |||
| 6 | 'text' | 'autocomplete' | 'select' | 'multi-select' | 'range' | 'range-slider' | 'checkbox' | 'date' | 'date-range' | 'text' | |||
| 7 | AutocompleteProps | ({ column, table, rangeFilterIndex}) => AutocompleteProps | | Mantine Autocomplete Docs | ||
| 8 | CheckboxProps | ({ column, table }) => CheckboxProps | | Mantine Checkbox Props | ||
| 9 | MultiSelectProps | ({ column, table }) => MultiSelectProps | | Mantine MultiSelect Docs | ||
| 10 | SelectProps | ({ column, table }) => SelectProps | | Mantine Select Docs | ||
| 11 | TextInputProps | ({ column, rangeFilterIndex, table }) => TextInputProps | | Mantine TextInput Docs | ||
| 12 | | | |||
Relevant State Options
# | State Option | Type | Default Value | More Info Links | |
|---|---|---|---|---|---|
| 1 | { [key: string]: MRT_FilterFn } | | |||
| 2 | Array<{id: string, value: unknown}> | {} | TanStack Table Filters Docs | ||
| 3 | boolean | false | |||
Disable Filtering Features
Various subsets of filtering features can be disabled. If you want to disable filtering completely, you can set the enableColumnFilters table option to false to remove all filters from each column. Alternatively, enableColumnFilter can be set to false for individual columns.
enableFilters can be set to false to disable both column filters and the global search filter.
Filter Variants
Mantine React Table has several built-in filter variants for advanced filtering. These can be specified on a per-column basis using the filterVariant option. The following variants are available:
'text'- shows the default text field'autocomplete'- shows an autocomplete text field with the options from faceted values or specified inmantineFilterAutocompleteProps.dataarray.'select'- shows a select dropdown with the options from faceted values or specified inmantineFilterSelectProps.dataarray.'multi-select'- shows a select dropdown with the options from faceted values or specified inmantineFilterMultiSelectProps.dataand allows multiple selections with checkboxes'range'- shows min and max text fields for filtering a range of values'range-slider'- shows a slider for filtering a range of values'date'- shows a date picker for filtering by date values'date-range'- shows a date range picker for filtering by date ranges'checkbox'- shows a checkbox for filtering by'true'or'false'values
Account Status | Name | Hire Date | Age | Salary | City | State |
|---|---|---|---|---|---|---|
| Active | Tanner Linsley | 2/23/2016 | 42 | $100,000.00 | San Francisco | California |
| Active | Kevin Vandy | 2/23/2019 | 51 | $80,000.00 | Richmond | Virginia |
| Inactive | John Doe | 2/23/2014 | 27 | $120,000.00 | Riverside | South Carolina |
| Active | Jane Doe | 2/25/2015 | 32 | $150,000.00 | San Francisco | California |
| Inactive | John Smith | 6/11/2023 | 42 | $75,000.00 | Los Angeles | California |
| Active | Jane Smith | 2/23/2019 | 51 | $56,000.00 | Blacksburg | Virginia |
| Inactive | Samuel Jackson | 2/23/2010 | 27 | $90,000.00 | New York | New York |
Faceted Values for Filter Variants
Faceted values are a list of unique values for a column that gets generated under the hood from table data when the enableFacetedValues table option is set to true. These values can be used to populate the autocomplete suggestions, select dropdowns, or the min and max values for the 'range-slider' variant. This means that you no longer need to manually specify the filter select data props for these variants manually, especially if you are using client-side filtering.
Name | Salary | City | State |
|---|---|---|---|
| Tanner Linsley | $100,000.00 | San Francisco | California |
| Kevin Vandy | $80,000.00 | Richmond | Virginia |
| John Doe | $120,000.00 | Riverside | South Carolina |
| Jane Doe | $150,000.00 | San Francisco | California |
| John Smith | $75,000.00 | Los Angeles | California |
| Jane Smith | $56,000.00 | Blacksburg | Virginia |
| Samuel Jackson | $90,000.00 | New York | New York |
Custom Faceted Values
If you are using server-side pagination and filtering, you can still customize the faceted values output with the getFacetedUniqueValues and getFacetedMinMaxValues table options.
Column Filter Display Modes
By default, column filters inputs show below the column header. You can switch to a more "excel-like" UI by setting the columnFilterDisplayMode table option to 'popover'. This will show a filter icon in the column header that can be clicked to open a popover with the filter input.
Alternatively, if you want to render your own column filter UI in a separate sidebar, but still want to use the built-in filtering functionality, you can set the columnFilterDisplayMode table option to 'custom'.
ID | First Name | Last Name | Gender | Age |
|---|---|---|---|---|
| 1 | Hugh | Mungus | Male | 42 |
| 2 | Leroy | Jenkins | Male | 51 |
| 3 | Candice | Nutella | Female | 27 |
| 4 | Micah | Johnson | Other | 32 |
Custom Filter Functions
You can specify either a pre-built filterFn that comes with Mantine React Table or pass in your own custom filter functions.
Custom Filter Functions Per Column
By default, Mantine React Table uses a fuzzy filtering algorithm based on the popular match-sorter library from Kent C. Dodds. However, Mantine React Table also comes with numerous other filter functions that you can specify per column in the filterFn column options.
Pre-built MRT Filter Functions
Pre-built filter functions from Mantine React Table include
between,betweenInclusive,contains,empty,endsWith,equals,fuzzy,greaterThan,greaterThanOrEqualTo,lessThan,lessThanOrEqualTo,notEmpty,notEquals, andstartsWith. View these algorithms here
Pre-built TanStack Table Filter Functions
Pre-built filter functions from TanStack Table include
includesString,includesStringSensitive,equalsString,equalsStringSensitive,arrIncludes,arrIncludesAll,arrIncludesSome,weakEquals, andinNumberRange. View more information about these algorithms in the TanStack Table Filter docs.
You can specify either a pre-built filter function, from Mantine React Table or TanStack Table, or you can even specify your own custom filter function in the filterFn column option.
If you provide a custom filter function, it must have the following signature:
This function will be used to filter 1 row at a time and should return a boolean indicating whether or not that row passes the filter.
Add Custom Filter Functions
You can add custom filter functions to the filterFns table option. These will be available to all columns to use. The filterFn column option on a column will override any filter function with the same name in the filterFns table option.
Filter Modes
Enable Column Filter Modes (Filter Switching)
If you want to let the user switch between multiple different filter modes from a drop-down menu on the Filter Textfield, you can enable that with the enableColumnFilterModes table or column option. This will enable the filter icon in the filter text field to open a drop-down menu with the available filter modes when clicked.
Customize Filter Modes
You can narrow down the available filter mode options by setting the columnFilterModeOptions table or a column specific columnFilterModeOptions option.
Render Custom Filter Mode Menu
You can also render custom menu items in the filter mode drop-down menu by setting the renderColumnFilterModeMenuItems table or column option. This option is a function that takes in the column and returns an array of MenuItem components. This is useful if you want to add custom filter modes that are not included in Mantine React Table, or if you just want to render the menu in your own custom way
ID | First Name | Middle Name | Last Name | Age |
|---|---|---|---|---|
| 1 | Hugh | Jay | Mungus | 42 |
| 2 | Leroy | Leroy | Jenkins | 51 |
| 3 | Candice | Denise | Nutella | 27 |
| 4 | Micah | Henry | Johnson | 32 |
Expanded Leaf Row Filtering Options
If you are using the filtering features along-side either the grouping or expanding features, then there are a few behaviors and customizations you should be aware of.
Check out the Expanded Leaf Row Filtering Behavior docs to learn more about the filterFromLeafRows and maxLeafRowFilterDepth table options.
Manual Server-Side Column Filtering
A very common use case when you have a lot of data is to filter the data on the server, instead of client-side. In this case, you will want to set the manualFiltering table option to true and manage the columnFilters state yourself like so (can work in conjunction with manual global filtering).
Specifying
manualFilteringturns off all client-side filtering and assumes that thedatayou pass to<MantineReactTable />is already filtered.
See the full Remote Data example featuring server-side filtering, pagination, and sorting.
Customize Mantine Filter Input Components
You can customize the Mantine filter components by setting the mantineFilterTextInputProps table or column option.
ID | First Name | Last Name | Gender | Age |
|---|---|---|---|---|
| 1 | Hugh | Mungus | Male | 42 |
| 2 | Leroy | Jenkins | Male | 51 |
| 3 | Candice | Nutella | Female | 27 |
| 4 | Micah | Johnson | Other | 32 |
Custom Filter Components
If you need custom filter components that are much more complex than text-boxes and dropdowns, you can create and pass in your own filter components using the Filter column option.
Filter Match Highlighting
Filter Match Highlighting is a new featured enabled by default that will highlight text in the table body cells that matches the current filter query with a shade of the theme.colors.yellow color.
Filter Match Highlighting will only work on columns with the default text filter variant. Also, if you are using a custom Cell render override for a column, you will need to use the renderedCellValue param instead of cell.getValue() in order to preserve the filter match highlighting.
Disable Filter Match Highlighting
This feature can be disabled by setting the enableFilterMatchHighlighting table option to false.
View Extra Storybook Examples