Getting started

Mantine DataTable is built on top of Mantine and has no dependencies of its own. Its peer dependencies are @mantine/core and @mantine/hooks (version 9 or newer), react and react-dom (version 19 or newer), and clsx (version 2 or newer).

Start by creating an application with Mantine, then install mantine-datatable along with clsx:

yarn add mantine-datatable clsx

Next, import the necessary CSS files and make sure the styles are applied in the correct order.

For example, if you’re using a Next.js application with the app router, your root layout.tsx could look like this:

import { ColorSchemeScript, MantineProvider } from '@mantine/core';

import '@mantine/core/styles.layer.css';
import 'mantine-datatable/styles.layer.css';
import './layout.css';

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <head>
        <ColorSchemeScript defaultColorScheme="auto" />
      </head>
      <body>
        <MantineProvider defaultColorScheme="auto">{children}</MantineProvider>
      </body>
    </html>
  );
}

Then you can import the component and use it in your application like so:

'use client';

import { DataTable } from 'mantine-datatable';
import { Box } from '@mantine/core';
import { showNotification } from '@mantine/notifications';

export function GettingStartedExample() {
  return (
    <DataTable
      withTableBorder
      borderRadius="sm"
      withColumnBorders
      striped
      highlightOnHover
      // provide data
      records={[
        { id: 1, name: 'Joe Biden', bornIn: 1942, party: 'Democratic' },
        // more records...
      ]}
      // define columns
      columns={[
        {
          accessor: 'id',
          // this column has a custom title
          title: '#',
          // right-align column
          textAlign: 'right',
        },
        { accessor: 'name' },
        {
          accessor: 'party',
          // this column has custom cell data rendering
          render: ({ party }) => (
            <Box fw={700} c={party === 'Democratic' ? 'blue' : 'red'}>
              {party.slice(0, 3).toUpperCase()}
            </Box>
          ),
        },
        { accessor: 'bornIn' },
      ]}
      // execute this callback when a row is clicked
      onRowClick={({ record: { name, party, bornIn } }) =>
        showNotification({
          title: `Clicked on ${name}`,
          message: `You clicked on ${name}, a ${party.toLowerCase()} president born in ${bornIn}`,
          withBorder: true,
        })
      }
    />
  );
}

The above code will produce the following result:

#
Name
Party
Born in
1Joe Biden
DEM
1942
2Donald Trump
REP
1946
3Barack Obama
DEM
1961
4George W. Bush
REP
1946
5Bill Clinton
DEM
1946
6George H. W. Bush
REP
1924
7Ronald Reagan
REP
1911
8Jimmy Carter
DEM
1924
9Gerald Ford
REP
1913
10Richard Nixon
REP
1913
No records

Note that DataTable is a generic component: the type of the records is inferred from the records property, so callbacks such as render or onRowClick are fully typed and column accessor values are autocompleted, without any extra effort on your part.

Before browsing the usage examples and the type definitions, make sure you have a good understanding of how styling works.

Mantine DataTable is used and trusted by