
Skill
expanding
manage hierarchical row expansion in TanStack Table
Description
Expand hierarchical subrows or custom detail panels with rowExpandingFeature, expandedRowModel, getSubRows, getRowCanExpand, manualExpanding, and paginateExpandedRows. Load when expansion state changes but no UI appears.
SKILL.md
This skill builds on core, table-features, and client-vs-server. Expansion controls row-tree inclusion; the renderer owns disclosure controls and detail panels.
Setup
import {
createExpandedRowModel,
rowExpandingFeature,
tableFeatures,
} from '@tanstack/table-core'
type Node = { id: string; children?: Node[] }
export const features = tableFeatures({
rowExpandingFeature,
expandedRowModel: createExpandedRowModel(),
})
export const options = { getSubRows: (row: Node) => row.children }
Core Patterns
const detailOptions = { getRowCanExpand: () => true }
const isDetailOpen = row.getIsExpanded()
For custom detail UI, render an additional row/panel when isDetailOpen is true.
Common Mistakes
HIGH Omitting the subrow accessor
Wrong: const options = { data: nestedRows }
Correct: const options = { data: nestedRows, getSubRows: (row: Node) => row.children }
Nested object structure is not inferred automatically.
Source: docs/framework/react/guide/expanding.md#table-rows-as-expanded-data
HIGH Expecting detail markup from state
Wrong: row.toggleExpanded(true)
Correct: if (row.getIsExpanded()) renderDetail(row.original)
Table is headless and cannot render a custom detail panel.
Source: docs/framework/react/guide/expanding.md#custom-expanding-ui
HIGH Misreading pagination placement
Wrong: const options = { paginateExpandedRows: false }; const leafOnlyPages = true
Correct: const options = { paginateExpandedRows: false }; const descendantsStayWithParent = true
This option controls whether expansion happens before or after pagination; it does not make page size count only leaf rows.
Source: packages/table-core/src/features/row-expanding/rowExpandingFeature.types.ts
API Discovery
Inspect node_modules/@tanstack/table-core/dist/features/row-expanding/ for expansion state, row APIs, and model placement.
More skills from the table repository
View all 30 skillsaggregation
perform data aggregation in TanStack Table
Jul 26Data AnalysisFrontendTanStackapi-not-found
diagnose TanStack Table API errors
Jul 26DebuggingFrontendTanStackcell-selection
select rectangular cell ranges in tables
Jul 26Data AnalysisTanStackUI Componentsclient-vs-server
manage TanStack Table data pipelines
Jul 26Data PipelineFrontendPerformanceTanStackcolumn-faceting
build faceted filter UIs
Jul 26Data VisualizationFrontendTanStackcolumn-filtering
implement column filtering in TanStack Table
Jul 26Data AnalysisFrontendTanStack
More from TanStack
View publishercolumn-ordering
manage TanStack Table column ordering
table
Jul 26FrontendTanStackUI Componentscolumn-pinning
configure column pinning in TanStack Table
table
Jul 26CSSFrontendTanStackUI Componentscolumn-resizing
implement column resizing in TanStack Table
table
Jul 26FrontendTanStackUI Componentscolumn-sizing
configure column sizing in TanStack Table
table
Jul 26CSSFrontendTanStackUI Componentscolumn-visibility
manage column visibility in TanStack Table
table
Jul 26FrontendTanStackUI Componentscore
build data grids with TanStack Table
table
Jul 26Data AnalysisFrontendUI Components