Repository navigation
Releases: Monabbir-Ahmmad/shadcn-react-table
Releases · Monabbir-Ahmmad/shadcn-react-table
Release list
v1.1.1
v1.1.0
Minor Changes
- New:
positionToolbarAlertBanner: "head-overlay"shows the selection banner over the header row (as in Material React Table), so selecting rows doesn't move the table. - New:
createDataTableColumnHelper<TData>(), TanStack's column helper with the table's features filled in:accessorinfers each column's value type, andmetatakes the table's column options. - New:
layoutMode("semantic","grid","grid-no-grow") and per-columnmeta.grow: in grid mode columns keep their size and the spare width goes to the growing columns, by weight (as in Material React Table). - New: rows can be dragged (
enableRowOrdering,enableRowDragging) with row virtualization on: the dragged row stays rendered while it is dragged past the rendered window.
Patch Changes
- Changed: on phone-sized screens the rows-per-page control is the native picker, easier to use by touch than a popover.
v1.0.0
The first stable release. The API below is what 1.x keeps; see the
updating guide
for every rename.
Breaking changes
- Changed (breaking): the table's methods are on
table
(table.setDensity,table.beginRowEdit,table.autoSizeColumn…), its UI
state is intable.getState(), and its resolved options and refs are on
table.dataTable(typeDataTableOptionsResolved).table.tableInstance
and theDataTableConfigtype are gone. - Changed (breaking): UI state is set and controlled only through
initialState/state(with theon…Changecallbacks). Removed:
density,isFullscreen,showColumnFilters,advancedFilter,
globalFilterMode,defaultDensity,defaultShowColumnFilters,
defaultGlobalFilterMode,defaultAdvancedFilter. - Changed (breaking): renamed
onEditCellSave→onEditingCellSave,
onSaveRow→onEditingRowSave,onCreateRow→onCreatingRowSave,
renderToolbarActions→renderTopToolbarCustomActions. - Changed (breaking): column
metarenamedvariant→filterVariant,
options→filterSelectOptions,disableHighlight: true→
enableFilterMatchHighlighting: false,disableColumnActions: true→
enableColumnActions: false. - Changed (breaking):
pageSizeOptionsis auseDataTableoption, no
longer a<DataTable>prop. - Changed (breaking):
renderColumnActionsMenuItems,
renderRowActionMenuItemsandrenderCellActionMenuItemsreceive
internalMenuItemsandcloseMenu, and their return value is the whole
menu: includeinternalMenuItemsto keep the built-in items. The column
menu no longer appends your items after a separator, and with a row menu the
row's Edit action moves into it. - Changed (breaking):
<DataTable surfaceClassName>is replaced by
slotProps: { surface: { className } }. - Removed: the deprecated localization keys
advancedFiltersMatchLabel
andadvancedFiltersOf. - Breaking — TanStack Table v9: the engine now runs on
@tanstack/react-tablev9 (nativeuseTablewith every built-in feature,
row model, and sort/filter/aggregation function registered, so behaviour
matches 0.4.x). Re-add the block to pick up the new dependencies. See the
upgrade guide. - Removed options:
getCoreRowModeland the otherget*RowModeloptions;
the table wires every row model itself. - Instance APIs follow TanStack v9:
column.pin("start" | "end"),
column.getIsPinned()returns"start" | "end", and
getPrePaginationRowModel()is nowgetPrePaginatedRowModel()and
getPaginationRowModel()is nowgetPaginatedRowModel().getLeft*/
getRight*aregetStart*/getEnd*(leaf columns, visible cells, header
groups, total size), andcolumn.getStart("left")/column.getAfter("right")
take"start"/"end". Custom aggregation functions use
constructAggregationFn({ aggregate }). - Renamed options reach you too: the column option
sortingFnis now
sortFn, andstate.columnSizingInfo,initialState.columnSizingInfoand
onColumnSizingInfoChangeare nowcolumnResizingand
onColumnResizingChange. - Renamed: the
sortingFnsoption is nowsortFns(TanStack v9's name);
filterFnsandaggregationFnskeep their names. Functions can also go
inline on the column (filterFn,sortFn,aggregationFn); type inline
filter functions with the exportedDataTableFilterFn<TData>. - Row type must satisfy
RowData: TanStack v9 requires
Record<string, any> | Array<any>, sounknownis no longer accepted.
DataTableInstance<unknown>anduseDataTable<unknown>need a concrete row
type;DataTableInstancewith no type argument now defaults toRowData. table.optionsis now the options object the table was created with on
each render (TanStack v9's React adapter behaviour), not TanStack's
internally merged options with feature defaults.- Type registration: the block's types register a small TanStack feature
(dataTableInstanceFeature) through TanStack'sPlugins/
Table_FeatureMapinterfaces, scoped to tables built with the block's
feature set. Other TanStack tables in your app are unaffected, except ones
typedTable<any, …>. - Changed (breaking): the component that calls
useDataTableno longer
re-renders when the table's state changes;<DataTable>subscribes to what
it shows. Code that reads the state during that component's render (a
"3 selected" label) needsstateSelector: (state) => state.rowSelection, or
table.Subscribearound the part that shows it. Event handlers, effects and
the table's render props are unaffected.
New
- New: a custom
cellrenderer getsrenderedCellValue: the cell's
value with its matches to the global search or a column filter marked (as
in Material React Table), so custom cells keep the match highlighting. - New: drag rows between tables and onto drop zones:
DataTableDndProvider,enableRowDragging,onRowDragEnd({ row, table, over })anduseDataTableDropZone(id), with keyboard support, a floating
preview and adata-drop-targetattribute on the hovered table. - New: columns resize from the keyboard: the resize handle is a focusable
separator (arrow keys ±10px, Shift ±50px, Home/End to the limits, Enter to
fit) that reports its width to screen readers. - New: a column with several aggregations (
aggregationFn: ["sum", "mean"]) shows each labelled, formatted result in grouped rows; labels come
from the new optionallocalization.aggregationFns. - New: when filters or the search hide every row, the empty table says
"No results found" (new localization keynoResultsFound, in every locale)
instead of "No records to display". - New: the global search box's open state is table state,
showGlobalFilter(initialState,state,onShowGlobalFilterChange,
table.setShowGlobalFilter). - New
slotPropsoption: extra props (classes, styles,data-*,
handlers, refs) for every part of the table — surface, rows, cells,
toolbars, search box, edit fields, dialog, checkboxes — as objects or
functions of the part's context. Columns can target their own cells with
meta.slotProps. Props merge with the table's own instead of replacing them. - New:
enableTableHead/enableTableFooterhide the header or footer
rows,enableExpandAllhides the expand-all toggle, and column
meta.visibleInShowHideMenu: falseleaves a column out of the show / hide
menu. - New editing options:
onEditingRowCancel/onCreatingRowCancel,
renderEditRowDialogContent/renderCreateRowDialogContent(with
internalEditComponents,save,cancel),positionCreatingRow
("top","bottom"or a row index), and
columneditSelectOptionsas a per-row function. - New filter variants:
autocomplete(text with suggestions),
datetime/datetime-range(compared to the minute) andtime/
time-range(compared by time of day), also in the advanced filter panel. - New: shift-click range selection (
enableBatchRowSelection, on by
default); single-row selection (enableMultiRowSelection: false) shows
radio buttons. - New: composition —
useDataTableInstance()reads the table from
anywhere inside it,DataTableProviderwraps your own layout, and the
toolbar, pagination, search, view-options, filter and menu parts are
exported.DataTableSlotsandSlotProptypes are exported too. - New:
displayColumnDefOptions(by column id, e.g."cn-select") and
defaultDisplayColumnoverride the columns the table adds itself. New
DisplayColumnIdtype. - New:
enableCellActionsturns on a built-in cell menu (Copy, Edit), and
enableClickToCopy(table and column) also takes"context-menu"or a
per-cell function. Newcopyicon slot. - New:
enableEditing(table option and columnmeta) takes a
(row) => booleanfunction to allow editing row by row;
table.dataTable.getCanEditRow(row)reads the table-level answer. - New custom functions:
filterFns,sortFnsandaggregationFns
options register your own functions by name. Columns use them with
filterFn/sortFn/aggregationFn: "name"; custom filter functions can
also be a column'smeta.filterModeand appear in the mode menus when listed
incolumnFilterModeOptions(column or new table-wide option) or the new
globalFilterModeOptions.FilterMode/GlobalFilterModeaccept any name. - New
DataTableColumnDef<TData>type (plusDataTableRow,
DataTableColumn,DataTableCell,DataTableHeader,DataTableState,
DataTableColumnPinningState,DataTableFeatures). Type your columns with
DataTableColumnDefinstead of TanStack'sColumnDef, which now needs a
feature-set parameter. - Added:
stateSelectoroption: re-render the component holding the table
when the selected part of the state changes. - Added: the table's UI state is TanStack table state:
density,
isFullscreen,showColumnFilters,columnFilterModes,
globalFilterMode,advancedFilter,showAdvancedFilterPanel,
editingCell,editingRowId,isCreating,rowDraftanddirectionare
intable.getState(), takeinitialStateand controlledstate, and reset
withtable.reset(). New callbacksonColumnFilterModesChange,
onShowAdvancedFilterPanelChange,onEditingCellChange,
onEditingRowIdChange,onIsCreatingChangeandonRowDraftChange. - Added: 37 locales (38 languages with English), each its own registry
item:data-table-locale-<lang>. Translations are adapted from Material
React Table; lines marked "needs review" await a native speaker. - Added: localization keys
language,true,false,dragStart,
dragOver,...
v0.4.2
- Changed default (surface color): the table surface, header and body
cells now use the shadcn card color (bg-card) instead of the page
background, so the table matches a<Card>out of the box. No visible change
in the default light theme; in dark mode the table reads as a raised card.
Restore the old look for one table with
surfaceClassName="[--card:var(--background)]". - Fix (row hover and state highlights): body cells are opaque (so pinned
columns cover scrolled content), which hid the row's hover, open-menu and
dragging highlights. Rows now publish their tint as--row-tintand cells
paint it over the card, so hover, open-menu, selected and dragging states all
show — including on rows withonRowClick. - Fix (pinned columns on selected rows): selected-row cells no longer turn
transparent, so content scrolled under a pinned column stays hidden. The
selected accent bar now sits on the row's first cell.
v0.4.1
- Fix (infinite scroll): the load trigger now fires when the table is
scrolled horizontally. The bottom sentinel is pinned to the horizontal
viewport (position: sticky; left: 0) so a wide, horizontally-scrolled table
still registers the intersection and requests the next chunk. - Changed default:
enableStickyFooternow defaults tofalse(wastrue).
enableStickyHeaderstill defaults totrue; opt into a pinned footer
explicitly when you have an aggregation/footer row.
v0.4.0
- Infinite row loading (
enableInfiniteScroll): append the next chunk of
rows as the user scrolls near the bottom, driven by controlled
onLoadMore/hasNextPage/isFetchingNextPageprops (maps directly onto
TanStack Query'suseInfiniteQuery). A bottom sentinel +IntersectionObserver
triggers the load;infiniteScrollThreshold(px, default 200) sets the
prefetch distance. Enabling it hides the pager and renders one growing page.
Works with or without row virtualization. NewloadingMorelocalization
string. See the infinite scroll guide. - Row height control (
rowHeight,getRowHeight): set a flat pixel height
for every row, or a per-row height viagetRowHeight(row) => number | "auto" | null."auto"wraps and grows the row to fit its content — even with column
resizing on (which otherwise clips cells to one line); a number pins the row
and clips overflow. Per-row heights feed the virtualizer estimate, and"auto"
rows are measured after render so variable heights virtualize accurately. See
the row height guide.
v0.3.0
- While
enableStickyHeaderis on (the default), the scroll surface now gets
a default viewport-bound max-height
(clamp(350px, calc(100dvh - 200px), 9999px)), so tall content (long
groups, trees, detail panels) scrolls internally under the pinned header
instead of stretching the page — matching MRT's sticky-implies-bounded
behavior. Override the bound with anymax-h-*viasurfaceClassName, or
remove it (and the pinning) withenableStickyHeader: false.
v0.2.0
The registry block at /r/data-table.json now carries this version in meta.version. See the updating guide for how to pull it into your project.
Breaking
- Removed the built-in export feature (#13, #17):
enableExport,exportFileName,exportToCsv/exportToExcel,DataTableExportMenu, theexport/exportCsv/exportExcellocalization strings, and theexport/fileCsv/fileExcelicons, along with thepapaparseandxlsxdependencies. The export guide now documents a bring-your-own recipe built on the table state model.
Fixed
usePageResetOnFilterChangeno longer resets the page on mount under React StrictMode, which wiped URL-persisted / controlled pagination in dev (#11, #15).
Added
- Selected rows now get a themeable
primary-tinted background across the full row in addition to the accent bar, shared by all row paths via the newSELECTED_ROW_CLASSconstant (#12, #16).
Full history: CHANGELOG.md