Skip to content

DataGrid API

API reference docs for the React DataGrid component. Learn about the props, CSS, and other APIs of this exported module.

Demos

Import

import { DataGrid } from '@toolpad-core/DataGrid';
// or
import { DataGrid } from '@toolpad-core';

Learn about the difference by reading this guide on minimizing bundle size.

Props

Props of the X DataGrid component are also available.

NameTypeDescription
dataProvider{ createOne?: func, deleteOne?: func, fields?: object, getMany: func, getOne?: func, idField?: object, updateOne?: func }

The data provider to resolve the displayed data. This object must be referentially stable.

heightnumber

The height of the datagrid in pixels. If left undefined, it adopts the height of its parent.

The component cannot hold a ref.

Inheritance

While not explicitly documented above, the props of the X DataGrid component are also available in DataGrid. You can take advantage of this to target nested components.

CSS classes

These class names are useful for styling with CSS. They are applied to the component's slots when specific states are triggered.

Class nameRule nameDescription
.actionsCellStyles applied to the root element of the cell with type="actions".
.aggregationColumnHeaderStyles applied to the root element of the column header when aggregated.
.aggregationColumnHeader--alignCenterStyles applied to the root element of the header when aggregation if headerAlign="center".
.aggregationColumnHeader--alignLeftStyles applied to the root element of the header when aggregation if headerAlign="left".
.aggregationColumnHeader--alignRightStyles applied to the root element of the header when aggregation if headerAlign="right".
.aggregationColumnHeaderLabelStyles applied to the aggregation label in the column header when aggregated.
.autoHeightStyles applied to the root element if autoHeight={true}.
.autosizingStyles applied to the root element while it is being autosized.
.booleanCellStyles applied to the icon of the boolean cell.
.cellStyles applied to the cell element.
.cell--editableStyles applied to the cell element if the cell is editable.
.cell--editingStyles applied to the cell element if the cell is in edit mode.
.cell--flexStyles applied to the cell element in flex display mode.
.cell--pinnedLeftStyles applied to the cell element if it is pinned to the left.
.cell--pinnedRightStyles applied to the cell element if it is pinned to the right.
.cell--rangeBottomStyles applied to the cell element if it is at the bottom edge of a cell selection range.
.cell--rangeLeftStyles applied to the cell element if it is at the left edge of a cell selection range.
.cell--rangeRightStyles applied to the cell element if it is at the right edge of a cell selection range.
.cell--rangeTopStyles applied to the cell element if it is at the top edge of a cell selection range.
.cell--selectionModeStyles applied to the cell element if it is in a cell selection range.
.cell--textCenterStyles applied to the cell element if align="center".
.cell--textLeftStyles applied to the cell element if align="left".
.cell--textRightStyles applied to the cell element if align="right".
.cell--withLeftBorderStyles applied the cell if showColumnVerticalBorder={true}.
.cell--withRightBorderStyles applied the cell if showColumnVerticalBorder={true}.
.cellCheckboxStyles applied to the cell checkbox element.
.cellEmptyStyles applied to the empty cell element.
.cellSkeletonStyles applied to the skeleton cell element.
.checkboxInputStyles applied to the selection checkbox element.
.columnHeaderStyles applied to the column header element.
.columnHeader--alignCenterStyles applied to the column header if headerAlign="center".
.columnHeader--alignLeftStyles applied to the column header if headerAlign="left".
.columnHeader--alignRightStyles applied to the column header if headerAlign="right".
.columnHeader--draggingStyles applied to the floating column header element when it is dragged.
.columnHeader--emptyGroupStyles applied to the empty column group header cell.
.columnHeader--filledGroupStyles applied to the column group header cell if not empty.
.columnHeader--filteredStyles applied to the column header if the column has a filter applied to it.
.columnHeader--lastStyles applied to the last column header element.
.columnHeader--movingStyles applied to the column header if it is being dragged.
.columnHeader--numericStyles applied to the column header if the type of the column is number.
.columnHeader--pinnedLeft
.columnHeader--pinnedRight
.columnHeader--sortableStyles applied to the column header if the column is sortable.
.columnHeader--sortedStyles applied to the column header if the column is sorted.
.columnHeader--withLeftBorder
.columnHeader--withRightBorderStyles applied the column header if showColumnVerticalBorder={true}.
.columnHeaderCheckboxStyles applied to the header checkbox cell element.
.columnHeaderDraggableContainerStyles applied to the column header's draggable container element.
.columnHeadersStyles applied to the column headers.
.columnHeaderTitleStyles applied to the column header's title element;
.columnHeaderTitleContainerStyles applied to the column header's title container element.
.columnHeaderTitleContainerContentStyles applied to the column header's title excepted buttons.
.columnSeparatorStyles applied to the column header separator element.
.columnSeparator--resizableStyles applied to the column header separator if the column is resizable.
.columnSeparator--resizingStyles applied to the column header separator if the column is being resized.
.columnSeparator--sideLeftStyles applied to the column header separator if the side is "left".
.columnSeparator--sideRightStyles applied to the column header separator if the side is "right".
.columnsManagementStyles applied to the columns management body.
.columnsManagementFooterStyles applied to the columns management footer element.
.columnsManagementHeaderStyles applied to the columns management header element.
.columnsManagementRowStyles applied to the columns management row element.
.container--bottomStyles applied to the bottom container.
.container--topStyles applied to the top container.
.detailPanelStyles applied to the detail panel element.
.detailPanelsStyles applied to the detail panels wrapper element.
.detailPanelToggleCellStyles applied to the detail panel toggle cell element.
.detailPanelToggleCell--expandedStyles applied to the detail panel toggle cell element if expanded.
.editBooleanCellStyles applied to root of the boolean edit component.
.editInputCellStyles applied to the root of the input component.
.filterFormStyles applied to the root of the filter form component.
.filterFormColumnInputStyles applied to the column input of the filter form component.
.filterFormDeleteIconStyles applied to the delete icon of the filter form component.
.filterFormLogicOperatorInputStyles applied to the link operator input of the filter form component.
.filterFormOperatorInputStyles applied to the operator input of the filter form component.
.filterFormValueInputStyles applied to the value input of the filter form component.
.filterIconStyles applied to the filter icon element.
.footerCellStyles applied to the root element of the cell inside a footer row.
.footerContainerStyles applied to the footer container element.
.groupingCriteriaCellStyles applied to the root element of the grouping criteria cell
.groupingCriteriaCellToggleStyles applied to the toggle of the grouping criteria cell
.headerFilterRowStyles applied to the column header filter row.
.iconButtonContainerStyles applied to the column header icon's container.
.iconSeparatorStyles applied to the column header separator icon element.
.mainStyles applied to the main container element.
.main--hasPinnedRightStyles applied to the main container element when it has right pinned columns.
.menuStyles applied to the menu element.
.menuIconStyles applied to the menu icon element.
.menuIconButtonStyles applied to the menu icon button element.
.menuListStyles applied to the menu list element.
.menuOpenStyles applied to the menu icon element if the menu is open.
.overlayStyles applied to the overlay element.
.overlayWrapperStyles applied to the overlay wrapper element.
.overlayWrapperInnerStyles applied to the overlay wrapper inner element.
.panelStyles applied to the panel element.
.panelContentStyles applied to the panel content element.
.panelFooterStyles applied to the panel footer element.
.panelHeaderStyles applied to the panel header element.
.panelWrapperStyles applied to the panel wrapper element.
.paperStyles applied to the paper element.
.pinnedColumnsStyles applied to the pinned columns.
.pinnedRowsStyles applied to the pinned rows container.
.pinnedRows--bottomStyles applied to the bottom pinned rows container.
.pinnedRows--topStyles applied to the top pinned rows container.
.pinnedRowsRenderZoneStyles applied to pinned rows render zones.
.rootStyles applied to the root element.
.root--densityComfortableStyles applied to the root element if density is "comfortable".
.root--densityCompactStyles applied to the root element if density is "compact".
.root--densityStandardStyles applied to the root element if density is "standard" (default).
.root--disableUserSelectionStyles applied to the root element when user selection is disabled.
.rowStyles applied to the row element.
.row--detailPanelExpandedStyles applied to the row if its detail panel is open.
.row--draggingStyles applied to the floating special row reorder cell element when it is dragged.
.row--dynamicHeightStyles applied to the row if it has dynamic row height.
.row--editableStyles applied to the row element if the row is editable.
.row--editingStyles applied to the row element if the row is in edit mode.
.row--firstVisibleStyles applied to the first visible row element on every page of the grid.
.row--lastVisibleStyles applied to the last visible row element on every page of the grid.
.rowCountStyles applied to the footer row count element to show the total number of rows. Only works when pagination is disabled.
.rowReorderCellStyles applied to the root element of the row reorder cell
.rowReorderCell--draggableStyles applied to the root element of the row reorder cell when dragging is allowed
.rowReorderCellContainerStyles applied to the row reorder cell container element.
.rowReorderCellPlaceholderStyles applied to the row's draggable placeholder element inside the special row reorder cell.
.scrollAreaStyles applied to both scroll area elements.
.scrollArea--leftStyles applied to the left scroll area element.
.scrollArea--rightStyles applied to the right scroll area element.
.scrollbarStyles applied to the scrollbars.
.scrollbar--horizontalStyles applied to the horizontal scrollbar.
.scrollbar--verticalStyles applied to the horizontal scrollbar.
.selectedRowCountStyles applied to the footer selected row count element.
.sortIconStyles applied to the sort icon element.
.toolbarContainerStyles applied to the toolbar container element.
.toolbarFilterListStyles applied to the toolbar filter list element.
.treeDataGroupingCellStyles applied to the root of the grouping column of the tree data.
.treeDataGroupingCellToggleStyles applied to the toggle of the grouping cell of the tree data.
.virtualScrollerStyles applied to the virtualization container.
.virtualScrollerContentStyles applied to the virtualization content.
.virtualScrollerContent--overflowedStyles applied to the virtualization content when its height is bigger than the virtualization container.
.virtualScrollerRenderZoneStyles applied to the virtualization render zone.
.withBorderColorStyles applied to cells, column header and other elements that have border. Sets border color only.
.withVerticalBorderStyles applied the grid if showColumnVerticalBorder={true}.

You can override the style of the component using one of these customization options: