Basic Example
Mantine React Table enables client-side sorting, filtering, search, pagination, column hiding, and more by default. These features can easily be disabled or customized further, but here is a showcase of their default behavior. Be sure to check out a more Advanced Example to see how more features can be customized.
First Name | Last Name | Address | City | State |
---|---|---|---|---|
Zachary | Davis | 261 Battle Ford | Columbus | Ohio |
Robert | Smith | 566 Brakus Inlet | Westerville | West Virginia |
Kevin | Yan | 7777 Kuhic Knoll | South Linda | West Virginia |
John | Upton | 722 Emie Stream | Huntington | Washington |
Nathan | Harris | 1 Kuhic Knoll | Ohiowa | Nebraska |
1-5 of 5
1import { useMemo } from 'react';2import {3MantineReactTable,4useMantineReactTable,5type MRT_ColumnDef,6} from 'mantine-react-table';78type Person = {9name: {10firstName: string;11lastName: string;12};13address: string;14city: string;15state: string;16};1718//nested data is ok, see accessorKeys in ColumnDef below19const data: Person[] = [20{21name: {22firstName: 'Zachary',23lastName: 'Davis',24},25address: '261 Battle Ford',26city: 'Columbus',27state: 'Ohio',28},29{30name: {31firstName: 'Robert',32lastName: 'Smith',33},34address: '566 Brakus Inlet',35city: 'Westerville',36state: 'West Virginia',37},38{39name: {40firstName: 'Kevin',41lastName: 'Yan',42},43address: '7777 Kuhic Knoll',44city: 'South Linda',45state: 'West Virginia',46},47{48name: {49firstName: 'John',50lastName: 'Upton',51},52address: '722 Emie Stream',53city: 'Huntington',54state: 'Washington',55},56{57name: {58firstName: 'Nathan',59lastName: 'Harris',60},61address: '1 Kuhic Knoll',62city: 'Ohiowa',63state: 'Nebraska',64},65];6667const Example = () => {68//should be memoized or stable69const columns = useMemo<MRT_ColumnDef<Person>[]>(70() => [71{72accessorKey: 'name.firstName', //access nested data with dot notation73header: 'First Name',74},75{76accessorKey: 'name.lastName',77header: 'Last Name',78},79{80accessorKey: 'address', //normal accessorKey81header: 'Address',82},83{84accessorKey: 'city',85header: 'City',86},87{88accessorKey: 'state',89header: 'State',90},91],92[],93);9495const table = useMantineReactTable({96columns,97data, //must be memoized or stable (useState, useMemo, defined outside of this component, etc.)98});99100return <MantineReactTable table={table} />;101};102103export default Example;
1import { useMemo } from 'react';2import { MantineReactTable, useMantineReactTable } from 'mantine-react-table';34//nested data is ok, see accessorKeys in ColumnDef below5const data = [6{7name: {8firstName: 'Zachary',9lastName: 'Davis',10},11address: '261 Battle Ford',12city: 'Columbus',13state: 'Ohio',14},15{16name: {17firstName: 'Robert',18lastName: 'Smith',19},20address: '566 Brakus Inlet',21city: 'Westerville',22state: 'West Virginia',23},24{25name: {26firstName: 'Kevin',27lastName: 'Yan',28},29address: '7777 Kuhic Knoll',30city: 'South Linda',31state: 'West Virginia',32},33{34name: {35firstName: 'John',36lastName: 'Upton',37},38address: '722 Emie Stream',39city: 'Huntington',40state: 'Washington',41},42{43name: {44firstName: 'Nathan',45lastName: 'Harris',46},47address: '1 Kuhic Knoll',48city: 'Ohiowa',49state: 'Nebraska',50},51];5253const Example = () => {54//should be memoized or stable55const columns = useMemo(56() => [57{58accessorKey: 'name.firstName', //access nested data with dot notation59header: 'First Name',60},61{62accessorKey: 'name.lastName',63header: 'Last Name',64},65{66accessorKey: 'address', //normal accessorKey67header: 'Address',68},69{70accessorKey: 'city',71header: 'City',72},73{74accessorKey: 'state',75header: 'State',76},77],78[],79);8081const table = useMantineReactTable({82columns,83data, //must be memoized or stable (useState, useMemo, defined outside of this component, etc.)84});8586return <MantineReactTable table={table} />;87};8889export default Example;
1import { useMemo } from 'react';2import { MantineReactTable, type MRT_ColumnDef } from 'mantine-react-table';34type Person = {5name: {6firstName: string;7lastName: string;8};9address: string;10city: string;11state: string;12};1314//nested data is ok, see accessorKeys in ColumnDef below15const data: Person[] = [16{17name: {18firstName: 'Zachary',19lastName: 'Davis',20},21address: '261 Battle Ford',22city: 'Columbus',23state: 'Ohio',24},25{26name: {27firstName: 'Robert',28lastName: 'Smith',29},30address: '566 Brakus Inlet',31city: 'Westerville',32state: 'West Virginia',33},34{35name: {36firstName: 'Kevin',37lastName: 'Yan',38},39address: '7777 Kuhic Knoll',40city: 'South Linda',41state: 'West Virginia',42},43{44name: {45firstName: 'John',46lastName: 'Upton',47},48address: '722 Emie Stream',49city: 'Huntington',50state: 'Washington',51},52{53name: {54firstName: 'Nathan',55lastName: 'Harris',56},57address: '1 Kuhic Knoll',58city: 'Ohiowa',59state: 'Nebraska',60},61];6263const Example = () => {64//should be memoized or stable65const columns = useMemo<MRT_ColumnDef<Person>[]>(66() => [67{68accessorKey: 'name.firstName', //access nested data with dot notation69header: 'First Name',70},71{72accessorKey: 'name.lastName',73header: 'Last Name',74},75{76accessorKey: 'address', //normal accessorKey77header: 'Address',78},79{80accessorKey: 'city',81header: 'City',82},83{84accessorKey: 'state',85header: 'State',86},87],88[],89);9091return <MantineReactTable columns={columns} data={data} />;92};9394export default Example;
View Extra Storybook Examples