Skip to content

Data grid - Master detail

Expand your rows to display additional information.

The master detail feature allows expanding a row to display additional information inside a panel. To use this feature, pass a function to the getDetailPanelContent prop with the content to be rendered inside the panel. Any valid React element can be used as the row detail, even another grid.

By default, the detail panel height is 500px. You can customize it by passing a function to the getDetailPanelHeight prop. This function must return either a number or the "auto" string. If it returns a number, then the panel will use that value (in pixels) for the height. If it returns "auto", then the height will be derived from the content.

<DataGridPro
  getDetailPanelContent={({ row }) => <div>Row ID: {row.id}</div>}
  getDetailPanelHeight={({ row }) => 100} // Optional, default is 500px.
/>

// or

<DataGridPro
  getDetailPanelContent={({ row }) => <div>Row ID: {row.id}</div>}
  getDetailPanelHeight={({ row }) => 'auto'} // Height based on the content.
/>

To expand a row, click on the + icon or press Space inside the detail toggle column. Returning null or undefined as the value of getDetailPanelContent will prevent the respective row from being expanded.

Order ID
Customer
Placed at
Currency
Total
1
Matheus
1/6/2025
EUR
76.125
2
Olivier
8/21/2024
JPY
908.05
3
Flavien
8/11/2024
CAD
13.335
4
Danail
5/10/2025
AUD
4,479.825
5
Alexandre
8/15/2024
USD
2,535.939
Total Rows: 5

Infer height from the content

Like dynamic row height, you can also derive the detail panel height from its content. For this, pass a function to the getDetailPanelHeight prop returning "auto", as below:

<DataGridPro getDetailPanelHeight={() => 'auto'} />

The following example demonstrates this option in action:

Order ID
Customer
Placed at
Currency
Total
1
Matheus
7/20/2024
GBP
760.043
2
Olivier
6/9/2025
MXN
3,029.607
3
Flavien
7/24/2024
CAD
5,101.793
4
Danail
1/26/2025
CAD
1,038.965
5
Alexandre
9/1/2024
MXN
3,765.773
Total Rows: 5

Controlling expanded detail panels

To control which rows are expanded, pass a list of row IDs to the detailPanelExpandedRowIds prop. Passing a callback to the onDetailPanelExpandedRowIds prop can be used to detect when a row gets expanded or collapsed.

On the other hand, if you only want to initialize the grid with some rows already expanded, use the initialState prop as follows:

<DataGridPro initialState={{ detailPanel: { expandedRowIds: [1, 2, 3] } }}>
Order ID
Customer
Placed at
Currency
Total
1
Matheus
1/21/2025
CAD
5.31
2
Olivier
9/18/2024
NZD
752.53
3
Flavien
4/5/2025
ARS
65.51
4
Danail
1/9/2025
THB
510.85
5
Alexandre
7/5/2024
TRY
361.71
Total Rows: 5

Using a detail panel as a form

As an alternative to the built-in row editing, a form component can be rendered inside the detail panel, allowing the user to edit the current row values.

The following demo shows integration with react-hook-form, but other form libraries are also supported.

Order ID
Customer
Email
1
Matheus
obled@tu.sz
2
Olivier
haramok@ovwan.fo
3
Flavien
ruhvum@ran.jm
4
Danail
jal@ri.ma
5
Alexandre
vutiaro@fitiwbo.az
Total Rows: 5

Customizing the detail panel toggle

To change the icon used for the toggle, you can provide a different component for the icon slot as follow:

<DataGridPro
  components={{
    DetailPanelExpandIcon: CustomExpandIcon,
    DetailPanelCollapseIcon: CustomCollapseIcon,
  }}
/>

If this is not sufficient, the entire toggle component can be overridden. To fully customize it, add another column with field: GRID_DETAIL_PANEL_TOGGLE_FIELD to your set of columns. The grid will detect that there is already a toggle column defined and it will not add another toggle in the default position. The new toggle component can be provided via renderCell in the same as any other column. By only setting the field, is up to you to configure the remaining options (e.g. disable the column menu, filtering, sorting). To already start with a few suggested options configured, spread GRID_DETAIL_PANEL_TOGGLE_COL_DEF when defining the column.

<DataGridPro
  columns={[
    {
      field: GRID_DETAIL_PANEL_TOGGLE_FIELD,
      renderCell: (params) => <CustomDetailPanelToggle {...params} />
    },
  ]}
/>

// or

<DataGridPro
  columns={[
    {
      ...GRID_DETAIL_PANEL_TOGGLE_COL_DEF, // Already contains the right field
      renderCell: (params) => <CustomDetailPanelToggle {...params}>
    },
  ]}
/>

This approach can also be used to change the location of the toggle column, as shown below.

Order ID
Customer
Placed at
Currency
Total
1
Matheus
10/25/2024
JPY
924.81
2
Olivier
12/20/2024
USD
90.79
3
Flavien
6/27/2024
NZD
843.67
4
Danail
6/17/2025
ARS
281.88
5
Alexandre
4/7/2025
JPY
562.71
Total Rows: 5

Disable detail panel content scroll

By default, the detail panel has a width that is the sum of the widths of all columns. This means that when a horizontal scrollbar is present, scrolling it will also scroll the panel content. To avoid this behavior, set the size of the detail panel to the outer size of the grid. Use apiRef.current.getRootDimensions() to get the latest dimension values. Finally, to prevent the panel from scrolling, set position: sticky and left: 0.

The following demo shows how this can be achieved. Notice that the toggle column is pinned to make sure that it will always be visible when the grid is scrolled horizontally.

Order ID
Customer
Email
Placed at
Currency
Address
City
Total
1
Matheus
job@beru.gt
2/22/2025
GBP
1669 Rurwu Road
Mawmateca, Poland
1,068.165
2
Olivier
vujdofi@dub.zw
9/3/2024
JPY
1341 Gawaw Parkway
Henhibo, Madagascar
1,034.67
3
Flavien
ju@nod.za
9/12/2024
JPY
476 Kulmo Glen
Vurligzu, Togo
635.88
4
Danail
hek@zir.sd
9/30/2024
HKD
688 Ehufe Street
Ohipaoto, New Caledonia
391.482
5
Alexandre
notbus@eteel.ge
6/16/2025
JPY
1863 Eswih Drive
Zubbohe, Reunion
85.428
6
José
ecjub@paesnag.fr
12/7/2024
BRL
46 Lomede Terrace
Kigzepufo, Cocos (Keeling) Islands
213.108
Total Rows: 6

apiRef

Signature:
getExpandedDetailPanels: () => GridRowId[]
Signature:
setExpandedDetailPanels: (ids: GridRowId[]) => void
Signature:
toggleDetailPanel: (id: GridRowId) => void