MRT logoMantine React Table

Customized Grouping Example

Here is an advanced example showing off various ways in which the expand column can be customized with column grouping features. See the Column Grouping Guide to learn more.

First Name
Last Name
Address
City
State
WavaHoppe4456 Towne EstatesEdmondNew Jersey
KamrenKemmer237 Reinger ViewKesslermouthNew Jersey
DillonHackett79266 Cronin RestConroylandColorado
WilberVon4162 Della RoadsChampaignIdaho
RonnyLowe4057 Burley ExtensionsSiennasteadAlaska
LaviniaKreiger24310 Aufderhar UnionCeceliachesterKentucky
TracyWilkinson7204 Claudine SummitFort MelanychesterTennessee
import '@mantine/core/styles.css';
import '@mantine/dates/styles.css'; //if using mantine date picker features
import 'mantine-react-table/styles.css'; //make sure MRT styles were imported in your app root (once)
import classes from './CSS.module.css';
import clsx from 'clsx';
import { useMemo } from 'react';
import {
  type MRT_ColumnDef,
  MRT_Table,
  useMantineReactTable,
} from 'mantine-react-table';
import { useMantineColorScheme } from '@mantine/core';
import { data, type Person } from './makeData';

export const Example = () => {
  const { colorScheme } = useMantineColorScheme();

  const columns = useMemo<MRT_ColumnDef<Person>[]>(
    () => [
      {
        accessorKey: 'firstName',
        header: 'First Name',
      },
      {
        accessorKey: 'lastName',
        header: 'Last Name',
      },
      {
        accessorKey: 'address',
        header: 'Address',
      },
      {
        accessorKey: 'city',
        header: 'City',
      },
      {
        accessorKey: 'state',
        header: 'State',
      },
    ],
    [],
  );

  const table = useMantineReactTable({
    columns,
    data,
    enableColumnActions: false,
    enableColumnFilters: false,
    enablePagination: false,
    enableSorting: false,
    mantineTableProps: {
      className: clsx(classes.table),
      highlightOnHover: false,
      striped: 'odd',
      withColumnBorders: true,
      withRowBorders: true,
      withTableBorder: true,
    },
  });

  //using MRT_Table instead of MantineReactTable if we do not want any of the toolbar features
  return <MRT_Table table={table} />;
};

export default Example;

View Extra Storybook Examples