Shadcn React Table

Search documentation

Search the docs

Detail panel

Provide renderDetailPanel to render an expandable panel beneath each row. An expand chevron column is added automatically, and row expansion is enabled for you.

Detail panel
GitHub
ID
AvaThompsonOwnerEngineeringactive22$45,000Jan 2, 2023
0%
LiamNguyenAdminMarketinginactive25$47,137Jan 13, 2023
9%
NoahSilvaEditorDesignpending28$49,274Jan 24, 2023
18%
EmmaCarterViewerSalesactive31$51,411Feb 4, 2023
27%
OliviaRossiOwnerSupportinactive34$53,548Feb 15, 2023
36%
WilliamWalkerAdminEngineeringpending37$55,685Feb 26, 2023
45%
SophiaPatelEditorMarketingactive40$57,822Mar 9, 2023
54%
JamesMullerViewerDesigninactive43$59,959Mar 20, 2023
63%
IsabellaParkOwnerSalespending46$62,096Mar 31, 2023
72%
LucasReyesAdminSupportactive49$64,233Apr 11, 2023
81%
$4,120,536
Rows per page
1–10 of 48

Usage

renderDetailPanel receives { row, table }. Return any React node — here a small definition list built from row.original.

const table = useDataTable({
  data,
  columns,
  getRowId: (row) => row.id,
  renderDetailPanel: ({ row }) => (
    <dl className="grid grid-cols-2 gap-2 p-4">
      <dt className="text-muted-foreground">Email</dt>
      <dd>{row.original.email}</dd>
      <dt className="text-muted-foreground">Phone</dt>
      <dd>{row.original.phone}</dd>
      <dt className="text-muted-foreground">Address</dt>
      <dd>{row.original.address}</dd>
    </dl>
  ),
})

return <DataTable table={table} />

Expansion is automatic

You don't need to configure getExpandedRowModel or add a chevron column yourself — defining renderDetailPanel turns on row expansion and inserts the expander column.

Positioning the expander

The expander column leads the data columns by default. Set positionExpandColumn: "last" to move it to the trailing edge.

useDataTable({
  renderDetailPanel: ({ row }) => <Detail row={row} />,
  positionExpandColumn: "last", // "first" | "last"
})