Skip to content

DataGrid

A fast and extensible React data table and React data grid, with filtering, sorting, aggregation, and more.

import { DataGrid, type GridColDef } from "@mui/x-data-grid";
const columns: GridColDef<(typeof rows)[number]>[] = [
{ field: "id", headerName: "ID", width: 90 },
{
field: "firstName",
headerName: "First name",
width: 150,
},
{
field: "lastName",
headerName: "Last name",
width: 150,
},
{
field: "age",
headerName: "Age",
type: "number",
width: 110,
},
];
const rows = [
{ id: 1, lastName: "Snow", firstName: "Jon", age: 14 },
{ id: 2, lastName: "Lannister", firstName: "Cersei", age: 31 },
{ id: 3, lastName: "Lannister", firstName: "Jaime", age: 31 },
{ id: 4, lastName: "Stark", firstName: "Arya", age: 11 },
{ id: 5, lastName: "Targaryen", firstName: "Daenerys", age: null },
{ id: 6, lastName: "Melisandre", firstName: null, age: 150 },
{ id: 7, lastName: "Clifford", firstName: "Ferrara", age: 44 },
{ id: 8, lastName: "Frances", firstName: "Rossini", age: 36 },
{ id: 9, lastName: "Roxie", firstName: "Harvey", age: 65 },
];
export default function DefaultExample() {
return (
<DataGrid
label="Game of Thrones Characters"
showToolbar
rows={rows}
columns={columns}
initialState={{
pagination: {
paginationModel: {
pageSize: 5,
},
},
}}
pageSizeOptions={[5]}
/>
);
}

The DataGrid is a complex control with many options for editing, filtering, sorting, pagination, and virtualization. The MUI DataGrid documentation contains numerous examples.

DataGrid offers three different feature levels: community (free), pro (paid), and premium (paid). Consult the DataGrid package list and MUI X licensing plans to determine which plan is needed for the features you will use.

When using the community level DataGrid there are several limitations to be aware of:

  • Limited to 100 rows displayed at one time. Need to use pagination to show larger data sets.
  • Sorting is limited to a single column.
  • Filtering is limited to a single condition.

Make sure the DataGrid is suitable for your use case. DataGrid and Table are both capable of displaying tabular data.

DataGrid supports tabular display with a significant amount of interactivity. It has row and cell selection and editing as first class concepts. The grid is a single tab stop with individual cells accessed by using the arrow keys.

Table provides a straightforward user interface for data with limited interactivity. Controls are accessed with the keyboard as normal by tabbing through each one individually.

Use caseDataGridTable
Displaying data with no interactivity❌✅
Selecting rows only❌✅
Displaying data with multiple interactive components per row✅✅
Spreadsheet experience where the user adjusts the values of cells✅❌
  • Restyled using StrataKit’s visual language.
  • Added hover and focus styling to differentiate editable cells with the pencil icon.
  • Changed default for checkboxSelection to true.
  • The showCellVerticalBorder and showColumnVerticalBorder props are not supported.

DataGrid supports editing values of different data types.

import * as React from "react";
import { DataGrid, GridCell, type GridColDef } from "@mui/x-data-grid";
interface Asset {
assetId: number;
assetName: string;
department: string;
purchaseDate: string;
cost: number;
inService: boolean;
}
const rows: Asset[] = [
{
assetId: 1001,
assetName: "Dell Precision 7680",
department: "Engineering",
purchaseDate: "2024-03-15",
cost: 2899,
inService: true,
},
{
assetId: 1002,
assetName: 'LG UltraFine 32" Monitor',
department: "Engineering",
purchaseDate: "2024-04-02",
cost: 899,
inService: false,
},
{
assetId: 1003,
assetName: "Microsoft Surface Laptop 7",
department: "Finance",
purchaseDate: "2025-01-10",
cost: 1599,
inService: true,
},
{
assetId: 1004,
assetName: "HP Color LaserJet Pro",
department: "Operations",
purchaseDate: "2022-06-21",
cost: 749,
inService: true,
},
{
assetId: 1005,
assetName: "DJI Matrice 350 RTK",
department: "Surveying",
purchaseDate: "2025-02-18",
cost: 12499,
inService: true,
},
{
assetId: 1006,
assetName: "Trimble X7 3D Scanner",
department: "Surveying",
purchaseDate: "2023-09-07",
cost: 18950,
inService: true,
},
{
assetId: 1007,
assetName: 'Apple iPad Pro 13"',
department: "Operations",
purchaseDate: "2025-05-14",
cost: 1299,
inService: true,
},
{
assetId: 1008,
assetName: "Lenovo ThinkPad P16",
department: "Engineering",
purchaseDate: "2023-11-29",
cost: 2549,
inService: true,
},
{
assetId: 1009,
assetName: "Brother ADS-4900W Scanner",
department: "Finance",
purchaseDate: "2022-10-12",
cost: 649,
inService: true,
},
{
assetId: 1010,
assetName: "Poly Studio X50",
department: "IT",
purchaseDate: "2024-07-01",
cost: 3199,
inService: true,
},
{
assetId: 1011,
assetName: "Cisco Catalyst 9300 Switch",
department: "IT",
purchaseDate: "2023-05-24",
cost: 4599,
inService: true,
},
{
assetId: 1012,
assetName: "Dell PowerEdge R760",
department: "IT",
purchaseDate: "2025-03-21",
cost: 8749,
inService: true,
},
{
assetId: 1013,
assetName: "Logitech Rally Bar",
department: "HR",
purchaseDate: "2024-01-17",
cost: 3499,
inService: true,
},
{
assetId: 1014,
assetName: "Canon imageRUNNER DX",
department: "Operations",
purchaseDate: "2021-08-30",
cost: 5299,
inService: false,
},
{
assetId: 1015,
assetName: "Microsoft Surface Hub 3",
department: "Executive",
purchaseDate: "2025-04-08",
cost: 10999,
inService: true,
},
{
assetId: 1016,
assetName: "Epson SureColor T3770",
department: "Surveying",
purchaseDate: "2022-12-15",
cost: 4499,
inService: false,
},
{
assetId: 1017,
assetName: "Samsung Galaxy Tab S10 Ultra",
department: "Field Services",
purchaseDate: "2025-06-03",
cost: 1399,
inService: true,
},
{
assetId: 1018,
assetName: "Dell Latitude 7450",
department: "HR",
purchaseDate: "2024-09-11",
cost: 1799,
inService: true,
},
{
assetId: 1019,
assetName: "Ricoh IM C4510",
department: "Finance",
purchaseDate: "2023-02-27",
cost: 6899,
inService: true,
},
{
assetId: 1020,
assetName: "Leica BLK360 Scanner",
department: "Surveying",
purchaseDate: "2024-11-05",
cost: 24990,
inService: true,
},
];
const costFormatter = new Intl.NumberFormat("en", {
style: "currency",
currency: "USD",
minimumFractionDigits: 0,
});
const columns: GridColDef<Asset>[] = [
{ field: "assetId", headerName: "ID", width: 90, editable: false },
{
field: "assetName",
headerName: "Name",
width: 150,
editable: true,
},
{
field: "department",
headerName: "Department",
width: 150,
type: "singleSelect",
editable: true,
valueOptions: [
"Engineering",
"Executive",
"Field Services",
"Finance",
"HR",
"IT",
"Operations",
"Surveying",
],
},
{
field: "purchaseDate",
headerName: "Purchase Date",
type: "date",
width: 110,
editable: true,
valueGetter: (_value, row) => new Date(row.purchaseDate),
},
{
field: "cost",
headerName: "Cost",
align: "right",
editable: true,
valueFormatter: (value?: number) =>
typeof value === "number" && !Number.isNaN(value)
? costFormatter.format(value)
: "-",
valueParser: (value: string) => Number.parseFloat(value),
},
{
field: "inService",
headerName: "In Service?",
type: "boolean",
editable: true,
},
];
function useCellWithEditDescription(id: string) {
const CellWithEditDescription = React.useMemo(
() => (props: React.ComponentProps<typeof GridCell>) => {
const isEditable = props.column.editable;
const existingDescribedBy = props["aria-describedby"];
const descriptionIds =
isEditable && existingDescribedBy
? `${id} ${existingDescribedBy}`
: isEditable
? id
: existingDescribedBy;
return <GridCell aria-describedby={descriptionIds} {...props} />;
},
[id],
);
return CellWithEditDescription;
}
export default function DataTypesExample() {
const editableDescriptionId = React.useId();
const CellWithEditDescription = useCellWithEditDescription(
editableDescriptionId,
);
return (
<>
<span hidden id={editableDescriptionId}>
editable
</span>
<DataGrid
label="Device Inventory"
showToolbar
rows={rows}
columns={columns}
getRowId={(row) => row.assetId}
initialState={{
pagination: {
paginationModel: {
pageSize: 10,
},
},
}}
pageSizeOptions={[5]}
checkboxSelection
disableRowSelectionOnClick
slots={{ cell: CellWithEditDescription }}
/>
</>
);
}

By default the DataGrid is configured to allow row selection. To use without row selection:

  • Set checkboxSelection={false} to hide the selection checkbox in the first column.
  • Set isRowSelectable={()=>false} to mark all rows as non selectable.
import { DataGrid, type GridColDef } from "@mui/x-data-grid";
const columns: GridColDef<(typeof rows)[number]>[] = [
{ field: "id", headerName: "ID", width: 90 },
{
field: "firstName",
headerName: "First name",
width: 150,
},
{
field: "lastName",
headerName: "Last name",
width: 150,
},
{
field: "age",
headerName: "Age",
type: "number",
width: 110,
},
];
const rows = [
{ id: 1, lastName: "Snow", firstName: "Jon", age: 14 },
{ id: 2, lastName: "Lannister", firstName: "Cersei", age: 31 },
{ id: 3, lastName: "Lannister", firstName: "Jaime", age: 31 },
{ id: 4, lastName: "Stark", firstName: "Arya", age: 11 },
{ id: 5, lastName: "Targaryen", firstName: "Daenerys", age: null },
{ id: 6, lastName: "Melisandre", firstName: null, age: 150 },
{ id: 7, lastName: "Clifford", firstName: "Ferrara", age: 44 },
{ id: 8, lastName: "Frances", firstName: "Rossini", age: 36 },
{ id: 9, lastName: "Roxie", firstName: "Harvey", age: 65 },
];
export default function Unselectable() {
return (
<DataGrid
isRowSelectable={() => false}
checkboxSelection={false}
label="Non Selectable Game of Thrones Characters"
showToolbar
rows={rows}
columns={columns}
initialState={{
pagination: {
paginationModel: {
pageSize: 5,
},
},
}}
pageSizeOptions={[5]}
/>
);
}
  • Use a DataGrid to handle large amounts of editable data.
  • Set the label prop to provide an accessible name for the grid.
  • Don’t use DataGrid where a simpler Table would work.
  • Don’t remove the selection checkbox without also removing the ability to select rows. The checkbox is required to help identify selected rows.