Data Grid - Getting started
Get started with the last React data grid you will need. Install the package, configure the columns, provide rows and you are set.
Installation
Using your favorite package manager, install @mui/x-data-grid-pro
for the full-featured enterprise grid, or @mui/x-data-grid
for the free community version.
// with npm
npm install @mui/x-data-grid
// with yarn
yarn add @mui/x-data-grid
The grid has a peer dependency on one MUI component. If you are not already using MUI in your project, you can install it with:
// with npm
npm install @mui/material
// with yarn
yarn add @mui/material
Quick start
First, you have to import the component as below.
To avoid name conflicts the component is named DataGridPro
for the full-featured enterprise grid, and DataGrid
for the free community version.
import { DataGrid } from '@mui/x-data-grid';
Define rows
Rows are key-value pair objects, mapping column names as keys with their values.
You should also provide an id
property on each row to allow delta updates and better performance.
Here is an example
const rows: GridRowsProp = [
{ id: 1, col1: 'Hello', col2: 'World' },
{ id: 2, col1: 'DataGridPro', col2: 'is Awesome' },
{ id: 3, col1: 'MUI', col2: 'is Amazing' },
];
Define columns
Comparable to rows, columns are objects defined with a set of attributes of the GridColDef
interface.
They are mapped to rows through their field
property.
const columns: GridColDef[] = [
{ field: 'col1', headerName: 'Column 1', width: 150 },
{ field: 'col2', headerName: 'Column 2', width: 150 },
];
You can import GridColDef
to see all column properties.
Demo
Putting it together, this all you need to get started, as you can see in this live and interactive demo:
import React from 'react';
import { DataGrid, GridRowsProp, GridColDef } from '@mui/x-data-grid';
const rows: GridRowsProp = [
{ id: 1, col1: 'Hello', col2: 'World' },
{ id: 2, col1: 'DataGridPro', col2: 'is Awesome' },
{ id: 3, col1: 'MUI', col2: 'is Amazing' },
];
const columns: GridColDef[] = [
{ field: 'col1', headerName: 'Column 1', width: 150 },
{ field: 'col2', headerName: 'Column 2', width: 150 },
];
export default function App() {
return (
<div style={{ height: 300, width: '100%' }}>
<DataGrid rows={rows} columns={columns} />
</div>
);
}
TypeScript
In order to benefit from the CSS overrides and default prop customization with the theme, TypeScript users need to import the following types. Internally, it uses module augmentation to extend the default theme structure.
// When using TypeScript 4.x and above
import type {} from '@mui/x-data-grid/themeAugmentation';
import type {} from '@mui/x-data-grid-pro/themeAugmentation';
const theme = createTheme({
components: {
// Use `MuiDataGrid` on both DataGrid and DataGridPro
MuiDataGrid: {
styleOverrides: {
root: {
backgroundColor: 'red',
},
},
},
},
});
Licenses
The data grid comes with two different licenses:
DataGrid, it's MIT licensed and available on npm as
@mui/x-data-grid
.DataGridPro, it's Commercially licensed and available on npm as
@mui/x-data-grid-pro
. The features only available in the commercial version are suffixed with a icon for the Pro plan or a icon for the Premium plan.You can check the feature comparison for more details. See Pricing for details on purchasing licenses.
Try DataGridPro for free
You are free to install and try DataGridPro
as long as it is not used for development of a feature intended for production.
Please take the component for a test run, no need to contact us.
Invalid license
If you have an enterprise grid running with an expired or missing license key, the grid displays a watermark, and a warning is shown in the console (MUI Unlicensed product).
Feature comparison
The following table summarizes the features available in the community DataGrid
and enterprise DataGridPro
components.
All the features of the community version are available in the enterprise one.
The enterprise components come in two plans: Pro and Premium.
Features | Community | Pro | Premium |
---|---|---|---|
Column | |||
Column groups | ๐ง | ๐ง | ๐ง |
Column spanning | ๐ง | ๐ง | ๐ง |
Column resizing | โ | โ | โ |
Column reorder | โ | โ | โ |
Column pinning | โ | โ | โ |
Row | |||
Row sorting | โ | โ | โ |
Row height | โ | โ | โ |
Row spanning | ๐ง | ๐ง | ๐ง |
Row reordering | โ | ๐ง | ๐ง |
Row pinning | โ | ๐ง | ๐ง |
Selection | |||
Single row selection | โ | โ | โ |
Checkbox selection | โ | โ | โ |
Multiple row selection | โ | โ | โ |
Cell range selection | โ | โ | ๐ง |
Filtering | |||
Quick filter | ๐ง | ๐ง | ๐ง |
Column filters | โ | โ | โ |
Multi-column filtering | โ | โ | โ |
Pagination | |||
Pagination | โ | โ | โ |
Pagination > 100 rows per page | โ | โ | โ |
Editing | |||
Row editing | โ | โ | โ |
Cell editing | โ | โ | โ |
Import & export | |||
CSV export | โ | โ | โ |
โ | โ | โ | |
Clipboard | โ | ๐ง | ๐ง |
Excel export | โ | โ | ๐ง |
Rendering | |||
Customizable components | โ | โ | โ |
Column virtualization | โ | โ | โ |
Row virtualization > 100 rows | โ | โ | โ |
Group & Pivot | |||
Tree data | โ | โ | โ |
Master detail | โ | ๐ง | ๐ง |
Grouping | โ | โ | ๐ง |
Aggregation | โ | โ | ๐ง |
Pivoting | โ | โ | ๐ง |
Misc | |||
Accessibility | โ | โ | โ |
Keyboard navigation | โ | โ | โ |
Localization | โ | โ | โ |
License key installation
Once you purchase a license, you'll receive a license key. This key should be provided to the enterprise package to remove the watermark and the warnings in the console.
import { LicenseInfo } from '@mui/x-data-grid-pro';
LicenseInfo.setLicenseKey(
'x0jTPl0USVkVZV0SsMjM1kDNyADM5cjM2ETPZJVSQhVRsIDN0YTM6IVREJ1T0b9586ef25c9853decfa7709eee27a1e',
);
The grid checks the key without making any network requests.
What's the expiration policy?
The licenses are perpetual, the license key will work forever. However, access to updates is not. If you install a new version of the component for which the license key has expired, you will trigger a watermark and console message. For instance, if you have a one-year license (default), you are not licensed to install a version that is two years in the future.
Support
For crowdsourced technical questions from expert MUI devs in our community. Also visited by the MUI Core team.
GitHub
We use GitHub issues exclusively as a bug and feature request tracker. If you think you have found a bug, or have a new feature idea, please start by making sure it hasn't already been reported or fixed. You can search through existing issues and pull requests to see if someone has reported one similar to yours.
StackOverflow
For crowdsourced answers from expert MUI developers in our community. StackOverflow is also visited from time to time by the maintainers of MUI.
Enterprise support
We provide a private support channel for enterprise customers.
Roadmap
Here is the public roadmap. It's organized by quarter.
โ ๏ธ Disclaimer: We operate in a dynamic environment, and things are subject to change. The information provided is intended to outline the general framework direction, for informational purposes only. We may decide to add or remove new items at any time, depending on our capability to deliver while meeting our quality standards. The development, releases, and timing of any features or functionality remains at the sole discretion of MUI. The roadmap does not represent a commitment, obligation, or promise to deliver at any time.