Theme

Getting started

If you're using Next.js, Vite, Create React App, Remix or Gatsby, make sure to have a look at Getting started with Mantine page.
Mantine DataTable depends on @mantine/core and @mantine/hooks.
Mantine also depends on @emotion/react (and @emotion/server when used with SSR frameworks).
Install the package and its dependencies:
yarn add @mantine/core@6 @mantine/hooks@6 @emotion/react mantine-datatable@6
pnpm i @mantine/core@6 @mantine/hooks@6 @emotion/react mantine-datatable@6
npm i @mantine/core@6 @mantine/hooks@6 @emotion/react mantine-datatable@6
Then you can import the component and use it in your application like so:
import { Text } from '@mantine/core';
import { DataTable } from 'mantine-datatable';
export default function GettingStartedExample() {
return (
<DataTable
withBorder
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
textAlignment: 'right',
},
{ accessor: 'name' },
{
accessor: 'party',
// this column has custom cell data rendering
render: ({ party }) => (
<Text weight={700} color={party === 'Democratic' ? 'blue' : 'red'}>
{party.slice(0, 3).toUpperCase()}
</Text>
),
},
{ accessor: 'bornIn' },
]}
// execute this callback when a row is clicked
onRowClick={({ name, party, bornIn }) =>
alert(`You clicked on ${name}, a ${party.toLowerCase()} president born in ${bornIn}`)
}
/>
);
}
The code above will produce the following result:
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
Browse the code examples to see the component in action and learn how to use it, and refer to the component properties for an exhaustive list of customizable options.

Mantine DataTable is trusted by

MIT LicenseSponsor the author
Built by Ionut-Cristian Florescu and these awesome people.
Please sponsor the project if you find it useful.
GitHub StarsNPM Downloads