API Reference
Column Options
All the column options that can be used in Shadcn Table
Many of the column options you can pass here are the same as the ones that you can pass to the TanStack Table ColumnDefs
Here is a list of all the column options you can specify in a column definition.
const columns = useMemo(
() => [
{
accessorKey: 'name',
header: 'Name',
// All of the options you can specify here
},
],
[],
);
const table = useShadcnTable({ columns, data });
return <ShadcnTable table={table} />;| Column Option | Type | Description |
|---|---|---|
| AggregatedCell | ({ cell, column, row, table }) => ReactNode | Define a custom cell render for an aggregated cell. |
| Cell | ({ cell, column, renderedCellValue, row, table }) => ReactNode | Define a custom cell render to add markup, styles, or conditional logic. |
| Edit | ({ cell, column, row, table }) => ReactNode | Define a custom edit component for cells in a column. |
| Filter | ({ column, header, table }) => ReactNode | Define a custom filter component in a column. |
| Footer | ReactNode | ({ column, footer, table }) => ReactNode | Render custom markup for a column footer. |
| GroupedCell | ({ cell, column, row, table }) => ReactNode | Define a custom cell render for a grouped cell. |
| Header | ReactNode | (({ column, header, table }) => ReactNode) | Render custom markup for a column header. |
| PlaceholderCell | ({ cell, column, row, table }) => ReactNode | Define a custom cell render for a placeholder cell. |
| accessorFn | (originalRow: TData) => any | Alternative to an accessorKey, define an accessor function instead of a string key. |
| accessorKey | string & keyof TData | If provided, the accessorKey will be used to point to which key in the data object should be used to access the data in this column. |
| aggregationFn | ST_AggregationFn<TData> | Array<ST_AggregationFn<TData>> | Specify which aggregate function(s) should be used for grouped columns: a built-in name, a name from the aggregationFns table option, a constructAggregationFn({ aggregate, merge? }) definition, or an array of those. TanStack Table core resolves the names, and an unknown name aggregates nothing. |
| columnFilterModeOptions | Array<string> | |
| columns | Array<ST_ColumnDef<TData>> | If using header groups, define an array of sub columns here. |
| editSelectOptions | DropdownOption[] | (({ cell, column, row, table, }) => DropdownOption[]) | |
| editVariant | 'text' | 'select' | |
| enableClickToCopy | boolean | 'context-menu' | ((cell: ST_Cell<TData>) => 'context-menu' | boolean) | Enable the click to copy feature for this column. |
| enableColumnActions | boolean | Enable or disable column actions for this column. |
| enableColumnDragging | boolean | Enable or disable column dragging for this column. |
| enableColumnFilter | boolean | Enable or disable column filtering for this column. Filter will not be shown if disabled. |
| enableColumnFilterModes | boolean | Filter modes are on by default; set false to hide the filter mode picker for this column. |
| enableColumnOrdering | boolean | Set it to false to lock the column: it cannot be dragged, and while another column drags it shows a lock with "Fixed" and refuses the drop. The column menu shows a disabled "Fixed position" item. The built-in display columns other than row actions are locked by default. |
| enableEditing | boolean | (row) => boolean | |
| enableFilterMatchHighlighting | boolean | Enable or disable filter match highlighting for this column. |
| enableGlobalFilter | boolean | |
| enableGrouping | boolean | |
| enableHiding | boolean | |
| enableMultiSort | boolean | |
| enablePinning | boolean | |
| enableResizing | boolean | |
| enableSorting | boolean | |
| filterDebounceMs | number | Overrides the columnFilterDebounceMs table option for this column. |
| filterFn | ST_FilterFn | A built-in filter name, a name registered through the filterFns table option, or a filter function. TanStack Table core resolves the name, and an unknown name filters nothing. After the table prepares its columns, columnDef.filterFn holds the current filter mode name; read it with getColumnFilterFnName(columnDef). |
| filterSelectOptions | Array<string | { label: string; value: string }> | |
| filterVariant | 'text' | 'select' | 'multi-select' | 'range' | 'range-slider' | 'checkbox' | 'autocomplete' | 'date' | 'date-range' | 'datetime' | 'datetime-range' | 'time' | 'time-range' | Specify whether the filter should be a text input or a select input, or other type of pre-built input. |
| getGroupingValue | (row: TData) => any) | Specify a value to be used for grouping rows on this column. If this option is not specified, the value derived from accessorKey / accessorFn will be used instead. |
| grow | boolean | number | If `layoutMode` is `'grid'` (the default) or `'grid-no-grow'`, set the flex grow value for a column, or `false`/0 to keep it at its set width. In the default layout display columns and pinned columns do not grow; a data column grows in the ratio of its size. |
| header* | string | |
| icon | ComponentType<ST_IconProps> | ReactNode | An icon component or element shown before the column label in the header, in the filter chips and in the column picker of the filter and sort editors. Nothing renders when it is unset. |
| id | string | |
| invertSorting | boolean | |
| maxSize | number | |
| meta | any | |
| minSize | number | |
| overflowTooltip | false | 'value' | ({ cell, column, row, table }) => ReactNode | The tooltip a cut-off body cell shows: false turns it off for this column, 'value' shows the cell value, a function renders the content. |
| renderCellActionMenuItems | { cell, closeMenu, column, internalMenuItems, row, staticColumnIndex, staticRowIndex, table }) => ReactNode[] | |
| renderColumnActionsMenuItems | ({ closeMenu, column, internalColumnMenuItems, table }) => ReactNode[] | |
| renderColumnFilterModeMenuItems | ||
| size | number | |
| sortDescFirst | boolean | |
| sortFn | SortFnOption | The sorting function to use for this column: the name of a built-in or custom (sortFns table option) sorting function, or a sorting function itself. TanStack Table core resolves the name, and an unknown name sorts nothing. |
| sortUndefined | 'first' | 'last' | false | 1 | -1 | |
| stColumnActionsButtonProps | IconButtonProps | ({ column, table }) => IconButtonProps | |
| stColumnDragHandleProps | IconButtonProps | ({ column, table }) => IconButtonProps | |
| stCopyButtonProps | ButtonProps | ({ cell, column, row, table }) => ButtonProps | |
| stEditTextFieldProps | TextFieldProps | ({ cell, column, row, table }) => TextFieldProps | |
| stFilterAutocompleteProps | AutocompleteProps | ({ column, rangeFilterIndex, table }) => AutocompleteProps | |
| stFilterCheckboxProps | CheckboxProps | ({ column, table }) => CheckboxProps | |
| stFilterDatePickerProps | DatePickerProps | ({ column, rangeFilterIndex, table }) => DatePickerProps | |
| stFilterDateTimePickerProps | DateTimePickerProps | ({ column, rangeFilterIndex, table }) => DateTimePickerProps | |
| stFilterSliderProps | SliderProps | ({ column, table}) => SliderProps | |
| stFilterTextFieldProps | TextFieldProps | ({ column, rangeFilterIndex, table }) => TextFieldProps | |
| stFilterTimePickerProps | TimePickerProps | ({ column, rangeFilterIndex, table }) => TimePickerProps | |
| stTableBodyCellProps | TableCellProps | ({ cell, table }) => TableCellProps | |
| stTableFooterCellProps | TableCellProps | ({ column, table }) => TableCellProps | |
| stTableHeadCellProps | TableCellProps | ({ column, table }) => TableCellProps | |
| visibleInShowHideMenu | boolean | Set to false if you want to hide a column from the show/hide menu. |
Wanna see the source code for this table? Check it out down below!