Tables and Data grid
Display records in a table or let people edit them in a spreadsheet-style grid.
See Choose a table or chart if you’re deciding how people should explore the data.
Choose Table or Data grid
Use Table for reports and lists read row by row. Use Data grid when people need to move between cells, select ranges, or edit values.
Both views can share a TanStack Table instance. TanStack handles column accessors and the current rows after sorting, filtering, or paging. Your app fetches data, validates edits, and saves changes.
Render your first table
Install Ghost UI and its component styles, then use TanStack Table v9 for this example.
Render Sources. You should see two columns, Source and Owner, with one row for Handbook.pdf.
Use accessorKey to read a row property. For a computed value, use accessorFn and give the column a stable id. Stable row and column IDs keep selection, edits, and pinning on the right records when the order changes.
Add sorting and other features
For client-side sorting, register rowSortingFeature in tableFeatures and configure the sorted row model. Filtering and pagination each need their own feature and row model.
Table.Data subscribes to the instance and renders headers and cells with table.FlexRender. Configure alignment and width with meta.alignment and meta.widthMode. For a custom cell layout, compose the Table parts directly.
Continue with state and editing. Use the TanStack v9 guides for engine details, and the component pages for anatomy and styling.
Reference and troubleshooting
TableDataProps accepts table, emptyContent, showFooter, and row/header/cell prop callbacks. DataGridTableProps accepts table plus grid interaction props, excluding raw rows/columns. Import these types from their respective component subpaths. Table API and Data grid API describe the exact view contracts.
- A feature method is missing. Check the feature registration and TanStack major version. The v8
useReactTableexamples use a different API. - A separate control shows old state. Subscribe to the relevant table state with
table.Subscribe. - An edit disappears. Apply it to your app’s rows and save it if it should persist.