Convert Figma logo to code with AI

icflorescu logomantine-datatable

The table component for your Mantine data-rich applications, supporting asynchronous data loading, column sorting, custom cell data rendering, context menus, nesting, Gmail-style batch row selection, dark theme, and more.

1,023
74
1,023
39

Top Related Projects

25,823

🤖 Headless UI for building powerful tables & datagrids for TS/JS - React-Table, Vue-Table, Solid-Table, Svelte-Table

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.

13,639

The best JavaScript Data Table for building Enterprise Applications. Supports React / Angular / Vue / Plain JavaScript.

Next Generation of react-bootstrap-table

Feature-rich and customizable data grid React component

Datatables for React using Material-UI

Quick Overview

Mantine DataTable is a powerful and flexible data table component for React applications, built on top of the Mantine UI library. It offers a rich set of features for displaying and interacting with tabular data, including sorting, pagination, and customizable styling.

Pros

  • Seamless integration with Mantine UI components and theming
  • Extensive customization options for columns, rows, and overall table appearance
  • Built-in support for common data table features like sorting, pagination, and row selection
  • TypeScript support for improved type safety and developer experience

Cons

  • Requires Mantine as a peer dependency, which may not be suitable for projects using other UI libraries
  • Learning curve for developers unfamiliar with Mantine's component structure and styling approach
  • Limited built-in filtering capabilities compared to some other data table libraries

Code Examples

  1. Basic usage with simple data:
import { DataTable } from 'mantine-datatable';

const data = [
  { id: 1, name: 'John', age: 30 },
  { id: 2, name: 'Jane', age: 25 },
  { id: 3, name: 'Bob', age: 40 },
];

function SimpleTable() {
  return (
    <DataTable
      columns={[
        { accessor: 'name', title: 'Name' },
        { accessor: 'age', title: 'Age' },
      ]}
      records={data}
    />
  );
}
  1. Implementing sorting and pagination:
import { useState } from 'react';
import { DataTable } from 'mantine-datatable';

function SortablePagedTable({ data }) {
  const [page, setPage] = useState(1);
  const [sortStatus, setSortStatus] = useState({ columnAccessor: 'name', direction: 'asc' });

  return (
    <DataTable
      columns={[
        { accessor: 'name', sortable: true },
        { accessor: 'age', sortable: true },
      ]}
      records={data}
      sortStatus={sortStatus}
      onSortStatusChange={setSortStatus}
      totalRecords={data.length}
      recordsPerPage={10}
      page={page}
      onPageChange={setPage}
    />
  );
}
  1. Custom column rendering:
import { DataTable } from 'mantine-datatable';
import { Badge } from '@mantine/core';

function CustomColumnTable({ data }) {
  return (
    <DataTable
      columns={[
        { accessor: 'name' },
        {
          accessor: 'status',
          render: ({ status }) => (
            <Badge color={status === 'active' ? 'green' : 'red'}>
              {status}
            </Badge>
          ),
        },
      ]}
      records={data}
    />
  );
}

Getting Started

To use Mantine DataTable in your React project:

  1. Install the package and its peer dependencies:
npm install mantine-datatable @mantine/core @mantine/hooks @emotion/react
  1. Import and use the DataTable component in your React application:
import { MantineProvider } from '@mantine/core';
import { DataTable } from 'mantine-datatable';

function App() {
  return (
    <MantineProvider>
      <DataTable
        columns={[/* your column definitions */]}
        records={[/* your data */]}
      />
    </MantineProvider>
  );
}

Make sure to wrap your application with MantineProvider for proper theming and styling.

Competitor Comparisons

25,823

🤖 Headless UI for building powerful tables & datagrids for TS/JS - React-Table, Vue-Table, Solid-Table, Svelte-Table

Pros of TanStack Table

  • Framework-agnostic, supporting React, Vue, Solid, and Svelte
  • More extensive feature set, including virtualization and advanced sorting
  • Larger community and ecosystem, with more plugins and extensions

Cons of TanStack Table

  • Steeper learning curve due to its flexibility and complexity
  • Requires more setup and configuration for basic use cases
  • Less opinionated styling, potentially requiring more custom CSS

Code Comparison

Mantine Datatable:

import { DataTable } from 'mantine-datatable';

<DataTable
  columns={[{ accessor: 'name' }, { accessor: 'age' }]}
  records={[{ name: 'John', age: 30 }, { name: 'Jane', age: 25 }]}
/>

TanStack Table:

import { useReactTable, getCoreRowModel, flexRender } from '@tanstack/react-table';

const table = useReactTable({
  data: [{ name: 'John', age: 30 }, { name: 'Jane', age: 25 }],
  columns: [{ accessorKey: 'name' }, { accessorKey: 'age' }],
  getCoreRowModel: getCoreRowModel(),
});

Summary

Mantine Datatable offers a simpler, more opinionated approach with built-in Mantine styling, while TanStack Table provides greater flexibility and features at the cost of increased complexity. Choose based on your project's specific needs and your team's familiarity with each library.

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.

Pros of Material-UI

  • Extensive component library with a wide range of UI elements
  • Large community and ecosystem, providing extensive documentation and third-party extensions
  • Highly customizable theming system with built-in support for dark mode

Cons of Material-UI

  • Steeper learning curve due to its comprehensive nature
  • Larger bundle size, which may impact initial load times
  • More opinionated design system, which may require more effort to deviate from the Material Design guidelines

Code Comparison

Material-UI:

import { DataGrid } from '@mui/x-data-grid';

const columns = [
  { field: 'id', headerName: 'ID', width: 70 },
  { field: 'firstName', headerName: 'First name', width: 130 },
];

<DataGrid rows={rows} columns={columns} pageSize={5} checkboxSelection />

Mantine-datatable:

import { DataTable } from 'mantine-datatable';

const columns = [
  { accessor: 'id', title: 'ID', width: 70 },
  { accessor: 'firstName', title: 'First name', width: 130 },
];

<DataTable records={records} columns={columns} />

Both libraries offer data table components, but Material-UI's DataGrid provides more built-in features like pagination and row selection out of the box, while Mantine-datatable focuses on simplicity and ease of use.

13,639

The best JavaScript Data Table for building Enterprise Applications. Supports React / Angular / Vue / Plain JavaScript.

Pros of ag-grid

  • More feature-rich with advanced functionalities like pivoting, grouping, and aggregation
  • Supports multiple frameworks (React, Angular, Vue) and vanilla JavaScript
  • Extensive documentation and community support

Cons of ag-grid

  • Steeper learning curve due to its complexity
  • Larger bundle size, which may impact performance for smaller projects
  • Commercial license required for some advanced features

Code Comparison

mantine-datatable:

<DataTable
  columns={[
    { accessor: 'name', width: 200 },
    { accessor: 'age', width: 80 },
  ]}
  records={data}
/>

ag-grid:

<AgGridReact
  columnDefs={[
    { field: 'name', width: 200 },
    { field: 'age', width: 80 },
  ]}
  rowData={data}
/>

Summary

ag-grid offers a more comprehensive set of features and wider framework support, making it suitable for complex enterprise applications. However, it comes with a steeper learning curve and potential licensing costs. mantine-datatable, while less feature-rich, provides a simpler API and is more lightweight, making it ideal for smaller projects or those already using the Mantine UI library. The code comparison shows that both libraries have similar basic usage, but ag-grid's API can become more complex as advanced features are utilized.

Next Generation of react-bootstrap-table

Pros of react-bootstrap-table2

  • More mature and established project with a larger community
  • Extensive documentation and examples available
  • Built-in support for Bootstrap styling

Cons of react-bootstrap-table2

  • Less frequent updates and maintenance
  • Heavier bundle size due to Bootstrap dependency
  • More complex API for advanced features

Code Comparison

mantine-datatable:

<DataTable
  columns={[
    { accessor: 'name', width: 200 },
    { accessor: 'age', width: 80 },
  ]}
  records={data}
/>

react-bootstrap-table2:

<BootstrapTable
  keyField='id'
  data={data}
  columns={[
    { dataField: 'name', text: 'Name' },
    { dataField: 'age', text: 'Age' },
  ]}
/>

Both libraries offer similar basic functionality, but mantine-datatable has a more concise API. react-bootstrap-table2 requires specifying a keyField and uses dataField instead of accessor. The text property in react-bootstrap-table2 is used for column headers, while mantine-datatable infers it from the accessor.

mantine-datatable provides a more modern and lightweight approach, focusing on essential features and customization. react-bootstrap-table2 offers a wider range of built-in functionalities but comes with a steeper learning curve and larger bundle size.

Feature-rich and customizable data grid React component

Pros of react-data-grid

  • More mature and battle-tested, with a larger community and longer development history
  • Offers more advanced features out-of-the-box, such as cell editing and custom cell renderers
  • Better performance for handling large datasets with virtualization

Cons of react-data-grid

  • Steeper learning curve due to its extensive API and configuration options
  • Less modern styling and theming capabilities compared to mantine-datatable
  • Requires more boilerplate code to set up basic functionality

Code Comparison

react-data-grid:

import ReactDataGrid from 'react-data-grid';

const columns = [
  { key: 'id', name: 'ID' },
  { key: 'name', name: 'Name' }
];

const rows = [
  { id: 1, name: 'John' },
  { id: 2, name: 'Jane' }
];

<ReactDataGrid columns={columns} rows={rows} />

mantine-datatable:

import { DataTable } from 'mantine-datatable';

const records = [
  { id: 1, name: 'John' },
  { id: 2, name: 'Jane' }
];

<DataTable
  columns={[
    { accessor: 'id', title: 'ID' },
    { accessor: 'name', title: 'Name' }
  ]}
  records={records}
/>

Both libraries offer powerful data grid components, but react-data-grid is more feature-rich and performant for complex use cases, while mantine-datatable provides a more modern and user-friendly approach with easier integration into Mantine-based projects.

Datatables for React using Material-UI

Pros of mui-datatables

  • More mature and widely adopted, with a larger community and ecosystem
  • Offers a wider range of built-in features and customization options
  • Better documentation and examples available

Cons of mui-datatables

  • Heavier bundle size due to more features and dependencies
  • Steeper learning curve for complex customizations
  • Less flexible for custom styling and layout modifications

Code Comparison

mantine-datatable:

<DataTable
  columns={[
    { accessor: 'name', width: 200 },
    { accessor: 'age', textAlignment: 'right' },
    { accessor: 'email' },
  ]}
  records={data}
/>

mui-datatables:

<MUIDataTable
  title={"Employee List"}
  data={data}
  columns={[
    { name: "name", label: "Name" },
    { name: "age", label: "Age" },
    { name: "email", label: "Email" },
  ]}
  options={options}
/>

Both libraries offer similar basic functionality for creating data tables, but mui-datatables provides more built-in options and customization out of the box. mantine-datatable has a simpler API and is more lightweight, making it easier to get started with for basic use cases. The choice between the two depends on the specific project requirements, desired features, and the developer's familiarity with the respective UI libraries (Mantine vs Material-UI).

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Mantine DataTable

Publish NPM & deploy docs workflow
NPM version License Stars Last commit Closed issues Downloads Language Sponsor the author

The lightweight, dependency-free, dark-theme aware table component for your Mantine UI data-rich applications, featuring asynchronous data loading support, pagination, intuitive Gmail-style additive batch rows selection, column sorting, custom cell data rendering, row expansion, nesting, context menus, and much more.

Mantine DataTable

⚠️ Mantine DataTable V7 is compatible with Mantine V7.
💡 If you're looking for the old version that works with Mantine V6, head over to Mantine DataTable V6.

Features

Trusted by the community

Emil Sorensen @ kapa.ai:

Mantine DataTable is a great component that’s core to our web app - it saves us a ton of time and comes with great styling and features out of the box

Giovambattista Fazioli @ Namecheap (@gfazioli is also a valuable Mantine DataTable contributor):

Thank you for the wonderful, useful, and beautiful DataTable that has allowed me to create several applications without any problem 👏

Mantine DataTable is used by developers and companies around the world, such as: Namecheap, EasyWP, CodeParrot.AI, OmicsStudio, SegmentX, Aquarino, Dera, kapa.ai, exdatis.ai, teachfloor, MARKUP, BookieBase, zipline, Pachtop, Ganymede, COH3 Stats, Culver City Rental Registry and many more.

If you're using Mantine DataTable in your project, please drop me a line at the email address listed in my GitHub profile and I'll be happy to add it to the list and on the documentation website.

Full documentation and examples

Visit icflorescu.github.io/mantine-datatable to view the full documentation and learn how to use it by browsing a comprehensive list of examples.

Mantine DataTable AI Bot

Mantine DataTable AI Bot, kindly provided by CodeParrot.AI, will help you understand this repository better. You can ask for code examples, installation guide, debugging help and much more.

Quickstart

Create a new application with Mantine, make sure to have the clsx peer dependency installed, then install the package with npm i mantine-datatable or yarn add mantine-datatable.

Import the necessary CSS files:

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

Make sure to apply the styles in the correct order:

/* layout.css */
/* 👇 Apply Mantine core styles first, DataTable styles second */
@layer mantine, mantine-datatable;

Use the component in your code:

'use client';

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

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,
        })
      }
    />
  );
}

Make sure to browse the comprehensive list of usage examples to learn how to unleash the full power of Mantine DataTable.

Other useful resources

Mantine DataTable works perfectly with Mantine Context Menu, a library built by the same author that enables you to enhance your UIs with desktop-grade, lightweight yet fully-featured context menus that respect the Mantine color scheme out of the box:

Mantine ContextMenu

Contributing

See the contributing guide in the documentation website or the repo CONTRIBUTING.md file for details.

💡 Most importantly, remember to make your PRs against the next branch.

Here's the list of people who have already contributed to Mantine DataTable:

Contributors list

Want to become a code contributor?

Support the project

If you find this package useful, please consider ❤️ sponsoring my work.
Your sponsorship will help me dedicate more time to maintaining the project and will encourage me to add new features and fix existing bugs.
If you're a company using Mantine, Mantine DataTable or Mantine ContextMenu in a commercial project, you can also hire my services.

Other means of support

If you can't afford to sponsor the project or hire my services, there are other ways you can support my work:

The more stars this repository gets, the more visibility it gains among the Mantine users community. The more users it gets, the more chances that some of those users will become active code contributors willing to put their effort into bringing new features to life and/or fixing bugs.

As the repository gain awareness, my chances of getting hired to work on Mantine-based projects will increase, which in turn will help maintain my vested interest in keeping the project alive.

Hiring the author

If you want to hire my services, don’t hesitate to drop me a line at the email address listed in my GitHub profile. I’m currently getting a constant flow of approaches, some of them relevant, others not so relevant. Mentioning “Mantine DataTable” in your text would help me prioritize your message.

Acknowledgements

🙏 Special thanks to Ani Ravi for being the first person to sponsor my work on this project! 💕 Additional thanks to all sponsors!

License

The MIT License.

NPM DownloadsLast 30 Days