API Reference
State Options
All the state options that can be used in Shadcn Table
Many of the state options you can pass here are the same as the ones you can pass to the TanStack Table useTable hook. Read them back from
table.state.
Here is a list of all the state options you can pass to initialState or state.
const table = useShadcnTable({
columns,
data,
//note: each individual state must be mutually exclusive to `initial state` or `state`
initialState: {
// all the state options you can pass here
},
state: {
// or here
},
});| State Option | Type | Description |
|---|---|---|
| columnFilterFns | { [key: string]: ST_FilterFn } | |
| columnFilters | Array<{id: string, value: unknown}> | an array of objects with id and value properties, representing the current filter values for each column |
| columnOrder | Array<string> | an array of strings representing the current order of the table columns |
| columnPinning | { start: Array<string>, end: Array<string> } | an object with start and end properties, each of which is an array of strings representing the columns that are pinned to the start (left in LTR) or end (right in LTR) side of the table |
| columnResizing | ST_ColumnResizingState | an object containing information about the column resize in progress |
| columnSizing | Record<string, number> | an object mapping column IDs to their current width in pixels |
| columnVisibility | Record<string, boolean> | an object mapping column IDs to a boolean indicating whether the column is currently visible |
| creatingRow | ST_Row | a variable representing the currently creating row |
| density | 'comfortable' | 'compact' | 'spacious' | |
| draggingColumn | ST_Column | null | a variable representing the currently dragged column |
| draggingRow | ST_Row | null | a variable representing the currently dragged row |
| editingCell | ST_Cell | a variable representing the currently editing cell |
| editingRow | ST_Row | a variable representing the currently editing row |
| expanded | Record<string, boolean> | boolean | |
| filterChips | { columnIds: string[]; openAnchor: 'chip' | 'header' | 'toolbar' | null; openColumnId: string | null } | The filter chips shown in the toolbar, in the order they were added, and the column whose filter editor is open with where it is anchored. A chip exists before it has a value. |
| globalFilter | any | |
| globalFilterFn | ST_FilterFn | |
| grouping | Array<string> | |
| hoveredColumn | ST_Column | null | |
| hoveredRow | ST_Row | null | |
| isFullScreen | boolean | |
| isLoading | boolean | |
| isSaving | boolean | |
| pagination | { pageIndex: number, pageSize: number } | |
| rowPinning | { top: string[], bottom: string[] } | an object with top and bottom properties, each of which is an array of strings representing the rows that are pinned to the top or bottom of the table |
| rowSelection | Record<string, boolean> | |
| showAlertBanner | boolean | |
| showColumnFilters | boolean | |
| showGlobalFilter | boolean | |
| showLoadingOverlay | boolean | Unset by default, so it follows isLoading until it is set. false turns it off. |
| showProgressBars | boolean | Unset by default, so it follows isSaving until it is set. false turns it off. |
| showSkeletons | boolean | Unset by default, so it follows isLoading until it is set. false turns it off. |
| showToolbarDropZone | boolean | |
| sorting | Array<{ id: string, desc: boolean }> | |
| viewSettings | ST_ViewSettingsState | The view settings panel values and the items pinned to the toolbar. rowNumbers and stickyHeader start from enableRowNumbers and enableStickyHeader. |
Wanna see the source code for this table? Check it out down below!