material-table
Datatable for React based on material-ui's table with additional features
Top Related Projects
🤖 Headless UI for building powerful tables & datagrids for TS/JS - React-Table, Vue-Table, Solid-Table, Svelte-Table
The best JavaScript Data Table for building Enterprise Applications. Supports React / Angular / Vue / Plain JavaScript.
Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
JavaScript data grid with a spreadsheet look & feel. Works with React, Angular, and Vue. Supported by the Handsontable team ⚡
React components for efficiently rendering large lists and tabular data
Next Generation of react-bootstrap-table
Quick Overview
material-table is a React component for creating powerful and feature-rich tables. It provides a wide range of customization options, including sorting, filtering, pagination, and row selection, making it a versatile tool for building data-driven applications.
Pros
- Highly Customizable: material-table offers a wide range of customization options, allowing developers to tailor the table to their specific needs.
- Responsive Design: The table is designed to be responsive, ensuring a consistent user experience across different devices and screen sizes.
- Extensive Feature Set: material-table includes a comprehensive set of features, such as sorting, filtering, pagination, and row selection, making it a powerful tool for data management.
- Active Development: The project has an active community and is regularly updated, ensuring that it stays up-to-date with the latest web development trends and best practices.
Cons
- Learning Curve: The extensive feature set and customization options can make the initial setup and configuration of material-table more complex than simpler table solutions.
- Performance Concerns: Depending on the size and complexity of the data being displayed, material-table may experience performance issues, especially when dealing with large datasets.
- Dependency on Material-UI: material-table is built on top of the Material-UI library, which means that developers must also be familiar with Material-UI to use the table effectively.
- Limited Functionality for Non-React Projects: material-table is primarily designed for React-based applications, which may limit its usefulness for developers working with other JavaScript frameworks or libraries.
Code Examples
Here are a few examples of how to use material-table in a React application:
import React from 'react';
import MaterialTable from 'material-table';
const columns = [
{ title: 'Name', field: 'name' },
{ title: 'Email', field: 'email' },
{ title: 'Phone', field: 'phone' },
];
const data = [
{ name: 'John Doe', email: 'john@example.com', phone: '555-1234' },
{ name: 'Jane Smith', email: 'jane@example.com', phone: '555-5678' },
{ name: 'Bob Johnson', email: 'bob@example.com', phone: '555-9012' },
];
const MyTable = () => {
return (
<MaterialTable
title="My Table"
columns={columns}
data={data}
options={{
filtering: true,
sorting: true,
paging: true,
}}
/>
);
};
export default MyTable;
This example demonstrates a basic usage of material-table, including defining the table columns and data, and configuring options such as filtering, sorting, and pagination.
import React, { useState } from 'react';
import MaterialTable from 'material-table';
const MyTable = () => {
const [data, setData] = useState([
{ id: 1, name: 'John Doe', email: 'john@example.com' },
{ id: 2, name: 'Jane Smith', email: 'jane@example.com' },
{ id: 3, name: 'Bob Johnson', email: 'bob@example.com' },
]);
const handleRowAdd = (newData) => {
setData([...data, newData]);
return Promise.resolve();
};
const handleRowUpdate = (newData, oldData) => {
const updatedData = [...data];
const index = updatedData.indexOf(oldData);
updatedData[index] = newData;
setData(updatedData);
return Promise.resolve();
};
const handleRowDelete = (oldData) => {
const updatedData = [...data];
const index = updatedData.indexOf(oldData);
updatedData.splice(index, 1);
setData(updatedData);
return Promise.resolve();
};
return (
<MaterialTable
title="My Editable Table"
columns={[
{ title: 'ID', field: 'id' },
{
Competitor Comparisons
🤖 Headless UI for building powerful tables & datagrids for TS/JS - React-Table, Vue-Table, Solid-Table, Svelte-Table
Pros of TanStack Table
- More flexible and framework-agnostic, supporting React, Vue, Solid, and Svelte
- Offers advanced features like virtualization and infinite scrolling out-of-the-box
- Highly customizable with a modular plugin system
Cons of TanStack Table
- Steeper learning curve due to its more complex API
- Requires more setup and configuration for basic use cases
- Less opinionated styling, which may require more work for consistent design
Code Comparison
Material Table:
import MaterialTable from 'material-table'
<MaterialTable
columns={[
{ title: 'Name', field: 'name' },
{ title: 'Age', field: 'age', type: 'numeric' }
]}
data={[
{ name: 'John', age: 30 },
{ name: 'Jane', age: 25 }
]}
/>
TanStack Table:
import { useTable } from '@tanstack/react-table'
const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow } = useTable({
columns: [{ Header: 'Name', accessor: 'name' }, { Header: 'Age', accessor: 'age' }],
data: [{ name: 'John', age: 30 }, { name: 'Jane', age: 25 }]
})
The best JavaScript Data Table for building Enterprise Applications. Supports React / Angular / Vue / Plain JavaScript.
Pros of ag-grid
- More feature-rich with advanced functionality like pivoting, grouping, and filtering
- Better performance for large datasets, handling millions of rows efficiently
- Extensive documentation and enterprise-level support options
Cons of ag-grid
- Steeper learning curve due to its complexity and extensive API
- Licensing costs for enterprise features, while material-table is fully open-source
- Heavier bundle size, which may impact initial load times
Code Comparison
material-table:
<MaterialTable
columns={[
{ title: 'Name', field: 'name' },
{ title: 'Age', field: 'age', type: 'numeric' }
]}
data={[
{ name: 'John', age: 30 },
{ name: 'Jane', age: 25 }
]}
/>
ag-grid:
<AgGridReact
columnDefs={[
{ headerName: 'Name', field: 'name' },
{ headerName: 'Age', field: 'age', type: 'numericColumn' }
]}
rowData={[
{ name: 'John', age: 30 },
{ name: 'Jane', age: 25 }
]}
/>
Both libraries offer React components for creating data grids, but ag-grid provides more customization options and advanced features at the cost of increased complexity.
Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
Pros of Material-UI
- Comprehensive UI component library with a wide range of components beyond tables
- Highly customizable with theming and styling options
- Large and active community with frequent updates and improvements
Cons of Material-UI
- Steeper learning curve due to its extensive API and features
- Larger bundle size, which may impact performance in smaller projects
- Not specifically optimized for table functionality like Material-Table
Code Comparison
Material-UI Table:
import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Paper } from '@mui/material';
<TableContainer component={Paper}>
<Table>
<TableHead>
<TableRow>
<TableCell>Name</TableCell>
<TableCell>Age</TableCell>
</TableRow>
</TableHead>
<TableBody>
{rows.map((row) => (
<TableRow key={row.name}>
<TableCell>{row.name}</TableCell>
<TableCell>{row.age}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</TableContainer>
Material-Table:
import MaterialTable from 'material-table';
<MaterialTable
columns={[
{ title: 'Name', field: 'name' },
{ title: 'Age', field: 'age', type: 'numeric' }
]}
data={[
{ name: 'John', age: 30 },
{ name: 'Jane', age: 25 }
]}
title="User Data"
/>
JavaScript data grid with a spreadsheet look & feel. Works with React, Angular, and Vue. Supported by the Handsontable team ⚡
Pros of Handsontable
- More feature-rich with advanced spreadsheet-like functionality
- Supports multiple frameworks (React, Angular, Vue) and vanilla JavaScript
- Extensive documentation and examples
Cons of Handsontable
- Steeper learning curve due to its complexity
- Commercial license required for some features
- Larger bundle size
Code Comparison
Handsontable:
const hot = new Handsontable(container, {
data: data,
rowHeaders: true,
colHeaders: true,
filters: true,
dropdownMenu: true
});
Material-table:
<MaterialTable
columns={[
{ title: 'Name', field: 'name' },
{ title: 'Age', field: 'age', type: 'numeric' }
]}
data={data}
options={{
filtering: true,
sorting: true
}}
/>
Summary
Handsontable offers more advanced spreadsheet-like features and supports multiple frameworks, making it suitable for complex data manipulation tasks. However, it comes with a steeper learning curve and potential licensing costs. Material-table, on the other hand, is more straightforward to use and integrate, especially for React projects, but may lack some of the advanced features found in Handsontable.
React components for efficiently rendering large lists and tabular data
Pros of react-virtualized
- Highly performant for rendering large lists and tabular data
- Flexible and customizable, with support for various layouts (grid, list, table)
- Offers windowing techniques to efficiently render only visible items
Cons of react-virtualized
- Steeper learning curve due to its more complex API
- Requires more manual setup and configuration compared to material-table
- Less out-of-the-box styling and theming options
Code Comparison
material-table:
<MaterialTable
columns={[
{ title: 'Name', field: 'name' },
{ title: 'Age', field: 'age', type: 'numeric' }
]}
data={[
{ name: 'John', age: 30 },
{ name: 'Jane', age: 25 }
]}
/>
react-virtualized:
<List
width={300}
height={300}
rowCount={1000}
rowHeight={20}
rowRenderer={({ key, index, style }) => (
<div key={key} style={style}>
Row {index}
</div>
)}
/>
Next Generation of react-bootstrap-table
Pros of react-bootstrap-table2
- Lightweight and focused on bootstrap styling
- Extensive documentation and examples
- Easy integration with existing Bootstrap projects
Cons of react-bootstrap-table2
- Less feature-rich compared to material-table
- Limited built-in styling options
- Requires separate installation of Bootstrap
Code Comparison
react-bootstrap-table2:
import BootstrapTable from 'react-bootstrap-table-next';
const columns = [{
dataField: 'id',
text: 'Product ID'
}, {
dataField: 'name',
text: 'Product Name'
}];
<BootstrapTable keyField='id' data={ products } columns={ columns } />
material-table:
import MaterialTable from 'material-table';
<MaterialTable
columns={[
{ title: 'Name', field: 'name' },
{ title: 'Surname', field: 'surname' }
]}
data={[{ name: 'Mehmet', surname: 'Baran' }]}
title="Demo Title"
/>
Both libraries offer easy-to-use table components, but material-table provides more built-in features and styling options out of the box. react-bootstrap-table2 is more lightweight and integrates well with existing Bootstrap projects, while material-table offers a more comprehensive solution with Material-UI styling.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
:warning: Please do not create pull requests that contains a lot of change. Because we are working on refactoring and testing. Just pull requests that fixes a bug with a few line changes.
material-table
A simple and powerful Datatable for React based on Material-UI Table with some additional features.
Roadmap
Key features
- Actions
- Component overriding
- Custom column rendering
- Detail Panel
- Editable
- Export
- Filtering
- Grouping
- Localization
- Remote Data
- Search
- Selection
- Sorting
- Styling
- Tree Data
- and more
Demo and documentation
You can access all code examples and documentation on our site material-table.com.
Support material-table
To support material-table visit SUPPORT page.
Issue Prioritizing
Issues would be prioritized according reactions count. is:issue is:open sort:reactions-+1-desc
filter would be use.
List issues according to reaction score
Prerequisites
The minimum React
version material-table supports is ^16.8.5
since material-table v1.36.1
. This is due to utilising react-beautiful-dnd
for drag & drop functionality which uses hooks.
If you use an older version of react we suggest to upgrade your dependencies or use material-table 1.36.0
.
Installation
1.Install package
To install material-table with npm
:
npm install material-table @material-ui/core --save
To install material-table with yarn
:
yarn add material-table @material-ui/core
2.Add material icons
There are two ways to use icons in material-table either import the material icons font via html OR import material icons and use the material-table icons
prop.
HTML
<link
rel="stylesheet"
href="https://fonts.googleapis.com/icon?family=Material+Icons"
/>
OR
Import Material icons
Icons can be imported to be used in material-table offering more flexibility for customising the look and feel of material table over using a font library.
To install @material-ui/icons with npm
:
npm install @material-ui/icons --save
To install @material-ui/icons with yarn
:
yarn add @material-ui/icons
If your environment doesn't support tree-shaking, the recommended way to import the icons is the following:
import AddBox from "@material-ui/icons/AddBox";
import ArrowDownward from "@material-ui/icons/ArrowDownward";
If your environment support tree-shaking you can also import the icons this way:
import { AddBox, ArrowDownward } from "@material-ui/icons";
Note: Importing named exports in this way will result in the code for every icon being included in your project, so is not recommended unless you configure tree-shaking. It may also impact Hot Module Reload performance. Source: @material-ui/icons
Example
import { forwardRef } from 'react';
import AddBox from '@material-ui/icons/AddBox';
import ArrowDownward from '@material-ui/icons/ArrowDownward';
import Check from '@material-ui/icons/Check';
import ChevronLeft from '@material-ui/icons/ChevronLeft';
import ChevronRight from '@material-ui/icons/ChevronRight';
import Clear from '@material-ui/icons/Clear';
import DeleteOutline from '@material-ui/icons/DeleteOutline';
import Edit from '@material-ui/icons/Edit';
import FilterList from '@material-ui/icons/FilterList';
import FirstPage from '@material-ui/icons/FirstPage';
import LastPage from '@material-ui/icons/LastPage';
import Remove from '@material-ui/icons/Remove';
import SaveAlt from '@material-ui/icons/SaveAlt';
import Search from '@material-ui/icons/Search';
import ViewColumn from '@material-ui/icons/ViewColumn';
const tableIcons = {
Add: forwardRef((props, ref) => <AddBox {...props} ref={ref} />),
Check: forwardRef((props, ref) => <Check {...props} ref={ref} />),
Clear: forwardRef((props, ref) => <Clear {...props} ref={ref} />),
Delete: forwardRef((props, ref) => <DeleteOutline {...props} ref={ref} />),
DetailPanel: forwardRef((props, ref) => <ChevronRight {...props} ref={ref} />),
Edit: forwardRef((props, ref) => <Edit {...props} ref={ref} />),
Export: forwardRef((props, ref) => <SaveAlt {...props} ref={ref} />),
Filter: forwardRef((props, ref) => <FilterList {...props} ref={ref} />),
FirstPage: forwardRef((props, ref) => <FirstPage {...props} ref={ref} />),
LastPage: forwardRef((props, ref) => <LastPage {...props} ref={ref} />),
NextPage: forwardRef((props, ref) => <ChevronRight {...props} ref={ref} />),
PreviousPage: forwardRef((props, ref) => <ChevronLeft {...props} ref={ref} />),
ResetSearch: forwardRef((props, ref) => <Clear {...props} ref={ref} />),
Search: forwardRef((props, ref) => <Search {...props} ref={ref} />),
SortArrow: forwardRef((props, ref) => <ArrowDownward {...props} ref={ref} />),
ThirdStateCheck: forwardRef((props, ref) => <Remove {...props} ref={ref} />),
ViewColumn: forwardRef((props, ref) => <ViewColumn {...props} ref={ref} />)
};
<MaterialTable
icons={tableIcons}
...
/>
Usage
Here is a basic example of using material-table within a react application.
import React, { Component } from "react";
import ReactDOM from "react-dom";
import MaterialTable from "material-table";
class App extends Component {
render() {
return (
<div style={{ maxWidth: "100%" }}>
<MaterialTable
columns={[
{ title: "Adı", field: "name" },
{ title: "Soyadı", field: "surname" },
{ title: "DoÄum Yılı", field: "birthYear", type: "numeric" },
{
title: "DoÄum Yeri",
field: "birthCity",
lookup: { 34: "Ä°stanbul", 63: "Åanlıurfa" },
},
]}
data={[
{
name: "Mehmet",
surname: "Baran",
birthYear: 1987,
birthCity: 63,
},
]}
title="Demo Title"
/>
</div>
);
}
}
ReactDOM.render(<App />, document.getElementById("react-div"));
Contributing
We'd love to have your helping hand on material-table
! See CONTRIBUTING.md for more information on what we're looking for and how to get started.
If you have any sort of doubt, idea or just want to talk about the project, feel free to join our chat on Gitter :)
Contributors
Code Contributors
This project exists thanks to all the people who contribute. [Contribute].
Financial Contributors
Become a financial contributor and help us sustain our community. [Contribute]
Individuals
Organizations
Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]
License
This project is licensed under the terms of the MIT license.
Top Related Projects
🤖 Headless UI for building powerful tables & datagrids for TS/JS - React-Table, Vue-Table, Solid-Table, Svelte-Table
The best JavaScript Data Table for building Enterprise Applications. Supports React / Angular / Vue / Plain JavaScript.
Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
JavaScript data grid with a spreadsheet look & feel. Works with React, Angular, and Vue. Supported by the Handsontable team ⚡
React components for efficiently rendering large lists and tabular data
Next Generation of react-bootstrap-table
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot