API Reference
ST Components
All the internal ST components that can be used to build your own custom table components
In previous versions of shadcn-table, you only had the option to use the <ShadcnTable /> component. Now in version 2, all internal ST components are exported for you to optionally use to build up your own custom table components.
<ShadcnTable />
For most use cases, you will probably just use the default <ShadcnTable /> component.
It accepts table options as props, but it can also simply accept the table instance as its only prop instead. You have the choice to use the useShadcnTable hook to create the table instance in your own scope or not. Using the table prop with the useShadcnTable hook is recommended, because it will give you more flexibility as your table features get more complex.
import { ShadcnTable, useShadcnTable } from '@/components/ui/shadcn-table';
//...
const table = useShadcnTable({
columns,
data,
enableRowPinning: true,
});
return <ShadcnTable table={table} />; //recommendedimport { ShadcnTable } from '@/components/ui/shadcn-table';
//...
return <ShadcnTable columns={columns} data={data} enableRowPinning />; //passing props instead is possibleDo not pass both a
tableprop and other table options as props. Additional table options passed to the<ShadcnTable />component will be ignored if atableprop is passed. Either specify all table options in theuseShadcnTablehook or pass all of them as props to the<ShadcnTable />component.
ST_* Sub Components
Shadcn Table now exports all of its internal components. You can use them for your own use cases.
<ST_TableProvider />
Most sub-components take no table prop (the toolbar components ST_FilterChips, ST_ColumnPicker, ST_SortPopover, ST_ViewSettingsButton, ST_ViewSettingsItems and ST_ScrollButtons take it explicitly). Those that render a row, cell, header or column read the table from it; the others read it from the context that <ShadcnTable /> provides. Outside <ShadcnTable />, wrap them in <ST_TableProvider table={table}>. See Compose with ST_TableProvider.
const table = useShadcnTable({ columns, data });
return (
<ST_TableProvider table={table}>
<ST_TableContainer />
</ST_TableProvider>
);<ST_DefaultsProvider />
Sets defaults for every table rendered below it. Its one prop is icons (Partial<ST_Icons>). Each table merges its icons in this order: ST_Default_Icons (the icon set your edition installed), then the nearest provider's icons, then the table's own icons option, so a table's own icon always wins for that key. A table outside any provider behaves as without one.
Providers nest: an inner provider merges its icons over the outer one's. useST_Defaults() returns the merged defaults of the nearest provider, or {} outside one.
import { ST_DefaultsProvider } from '@/components/ui/shadcn-table';
import { ST_Default_Icons as tabler } from '@/components/ui/shadcn-table/icons/tabler';
return (
<ST_DefaultsProvider icons={tabler}>
<OrdersTable />
<CustomersTable />
</ST_DefaultsProvider>
);Table Components
View Table Components Source Code on GitHub
<ST_TableLayout />
The <ST_TableLayout /> component is the outermost component of the table. Using this is pretty much the same thing as using the <ShadcnTable /> component, except that you cannot pass table options as props to it.
The layout component includes UI for the table and the toolbar components.
<ST_TableContainer />
The <ST_TableContainer /> component is the container for the table. It only contains the table ui, but none of the toolbar components.
This is a popular use case for tables that do not want the built-in toolbars, but still want all of the other table features.
<ST_Table />
The <ST_Table /> component contains the <table> element, and all of the table head, body, and footer components.
Be aware that using this deep of a component, you will lose out on row virtualization, modal editing, and full screen features. Use the above <ST_TableContainer /> if you want to use those features.
<ST_TableLoadingOverlay />
Shows a loading spinner over the table above the ST_Table component when the table is loading.
<ST_ScrollButtons />
The two scroll chevrons in the header row that appear on hover while columns are hidden sideways; a click scrolls 80 percent of the visible unpinned width. Takes the table prop and renders inside the scroll wrapper of <ST_TableContainer />. See the Scroll Cues Guide.
TableHead Components
View TableHead Components Source Code on GitHub
<ST_TableHead />
The <ST_TableHead /> component contains the <thead> element, and all of the table head rows.
<ST_TableHeadRow />
The <ST_TableHeadRow /> is a <tr> element that contains all of the table head cells in a row
<ST_TableHeadCell />
The <ST_TableHeadCell /> is a <th> element that contains all of the table head cell components. It contains all of the other table head cell components down below depending on which features are enabled.
<ST_TableHeadCellColumnActionsButton />
The chevron button at the end of a header cell that opens the column menu (the header label is the second trigger of the same menu). Takes open and onOpenChange to control the menu.
<ST_TableHeadCellSortLabel />
The sort arrow after a header label. It renders nothing while the column is unsorted and a plain arrow (not a button) while it is sorted, with the sort position when showSortIndex is on and more than one sort is active.
<ST_TableHeadCellFilterLabel />
The Filter Icon Button and Label next to a table header
<ST_TableHeadCellGrabHandle />
The Grab Handle Icon Button next to a table header used for column dragging
<ST_TableHeadCellResizeHandle />
The Resize Handle Icon Button next to a table header used for column resizing
<ST_TableHeadCellFilterContainer />
The Filter Container that contains the filter input and filter actions
<ST_TableHeadCellLockedOverlay />
The striped overlay and "Fixed" lock label a locked column (enableColumnOrdering: false) shows while another column is dragged. See Locked Columns.
TableBody Components
View TableBody Components Source Code on GitHub
<ST_TableBody />
The <ST_TableBody /> component contains the <tbody> element, and all of the table body rows. It has the ability to render multiple table bodies, depending on if static row pinning features are enabled and used.
<ST_TableBodyRow />
The <ST_TableBodyRow /> is a <tr> element that contains all of the table body cells in a row.
<ST_TableDetailPanel />
A row and all column-spanning row for rendering detail panels for a row.
<ST_TableBodyCell />
The <ST_TableBodyCell /> is a <td> element that surrounds the cell value or custom Cell render.
<ST_OverflowText />
Truncates its content to one line and shows a tooltip with the full content only when the content is cut off. Body cells use it for plain values; wrap the text of a custom Cell in it to opt in. Props: tooltip (other tooltip content), wrap (plain wrapping text, no tooltip), className. See the Overflow Tooltip Guide.
<ST_TableBodyCellValue />
Renders the value of a cell. This is a popular component to use as an alternative to TanStack Table's flexRender method. It renders everything inside of the <td>, but not the <td> itself.
<ST_TableBodyRowGrabHandle />
A button for grabbing a row for dragging.
<ST_TableBodyRowPinButton />
A button or buttons for pinning a row.
TableFooter Components
View TableFooter Components Source Code on GitHub
<ST_TableFooter />
The <ST_TableFooter /> component contains the <tfoot> element, and all of the table footer rows.
<ST_TableFooterRow />
The <ST_TableFooterRow /> is a <tr> element that contains all of the table footer cells in a row.
<ST_TableFooterCell />
The <ST_TableFooterCell /> is a <td> element that surrounds the cell value or custom Footer render.
Input Components
View Input Components Source Code on GitHub
<ST_EditCellTextField />
The textfield component for editing a cell value that can either show in a modal or table cell.
<ST_GlobalFilterTextField />
The search textfield component for global filtering.
<ST_FilterTextField />
The textfield component for filtering a column. A somewhat comprehensive component that can be a textfield, select, multi-select, or date picker.
<ST_FilterCheckbox />
The checkbox component for filtering a column by boolean values.
<ST_FilterRangeSlider />
The range slider component for filtering a column by a range of numbers.
<ST_FilterFilterRangeFields />
A Container component that will render two ST_FilterTextField components for filtering in a range (min and max).
<ST_SelectCheckbox />
A checkbox component for selecting a row or selecting all rows from the table header.
Toolbar Components
View Toolbar Components Source Code on GitHub
These components take the table as a table prop.
<ST_FilterChips />
The chip row of the default 'chips' filter display mode: one chip per filtered column, "+ Filter", "Clear filters", and the filter editor a column menu opens on its header cell. See the Filter Chips Guide.
<ST_ColumnPicker />
The searchable column list behind "+ Filter", the toolbar filter button and "Add sort". Renders inline, for a popover of your own.
<ST_SortPopover />
The sort button and sort editor: one row per sort rule with a drag handle, a column and a direction select and a remove button, plus "Add sort" and "Delete sort". variant="chip" renders the sort chip instead of the button. See the Sort Editor Guide.
<ST_ViewSettingsButton />
The view settings button and panel: one row per setting with a pin toggle, and "Reset view". See the View Settings Guide.
<ST_ViewSettingsItems />
The view settings items pinned to the toolbar, as icon buttons in panel order.
Menu Components
View Menu Components Source Code on GitHub
Each of these menus takes its opener as a trigger element: a press on it opens the menu and a second press closes it, and optional open and onOpenChange props control it. The older anchorEl and setAnchorEl props still open a menu without a trigger element.
import { Button } from '@/components/ui/button';
import { ST_ShowHideColumnsMenu } from '@/components/ui/shadcn-table';
<ST_ShowHideColumnsMenu trigger={<Button variant="outline">Columns</Button>} />;<ST_ColumnActionMenu />
The column menu of a header: sort, filter, pin, reset size, group, fixed position and hide items, each shown only when it applies. Takes the header. See the Column Actions Guide.
<ST_RowActionMenu />
The row actions menu opened by the dots button of the row actions column. Takes the row and handleEdit.
<ST_ShowHideColumnsMenu />
The columns menu: a switch per column, drag to reorder, and the show all, hide all, reset order and unpin all actions.
<ST_FilterOptionMenu />
The filter mode menu of a column (or of the global search). Takes the header for a column; with isSubMenu it renders as a submenu of the column menu.