Documentation · itzsa

React DataTable — @itzsa/table

Composable React DataTable for Next.js & TypeScript — sorting, pagination, filters, row selection, inline editing, CSV/Excel export, tree data, and keyboard navigation. Built on shadcn-style primitives; features are opt-in via props.

@itzsa/tableReact 18 / 19Tailwind v4

Installation#

Add the package, then wire Tailwind so utility classes inside the table are generated.

pnpm add @itzsa/table

In your global CSS (Tailwind v4):

@import "tailwindcss";
@source "../node_modules/@itzsa/table";
@import "@itzsa/table/styles.css";

Peers

Peer deps: react and react-dom ^18 or ^19. Import styles once at the app root.

Getting started#

Minimal client table. Serial numbers (SN) default on — pass sn={false} to hide.

import { DataTable } from "@itzsa/table";

const data = [
  { id: "1", name: "Ada Lovelace", role: "Mathematician" },
  { id: "2", name: "Alan Turing", role: "Computer scientist" },
];

const columns = [
  { key: "name", header: "Name", sortable: true },
  { key: "role", header: "Role" },
];

export function UsersTable() {
  return (
    <DataTable
      data={data}
      columns={columns}
      pageSize={10}
      showPagination
      sn
    />
  );
}

Opt-in by default

Almost every behavioral feature is off by default except SN and pagination. Turn on what you need with props like selectable, editable, showExport.

Examples#

Live demos — Preview / Code toggle; copy from the upper right.

Full-featured grid#

Cell edit, detail panel, filters, export, keyboard nav, actions, and custom page size (type or pick).

Row detailsSN
Actions
1
Alan Hopper
Design
Offline
2
Alan Lovelace
Design
Away
3
Alan Torvalds
Design
Active
4
Anders Hopper
Design
Active
5
Anders Lovelace
Design
Offline
6
Anders Torvalds
Design
Away
7
Dennis Johnson
Design
Away
8
Dennis Turing
Design
Active
9
Margaret Johnson
Design
Offline
10
Margaret Turing
Design
Away
11
Radia Hopper
Design
Away
12
Radia Lovelace
Design
Active
13
Radia Torvalds
Design
Offline
14
Ada Hopper
Engineering
Away
15
Ada Lovelace
Engineering
Active
16
Ada Torvalds
Engineering
Offline
17
Brendan Hopper
Engineering
Offline
18
Brendan Lovelace
Engineering
Away

Showing 118 of 100

Rows

Row edit mode#

editMode="row" — double-click, edit several fields, then save or cancel.

Actions
Ada Lovelace
Engineering
Active
Alan Lovelace
Design
Away
Grace Lovelace
Product
Offline
Margaret Lovelace
Support
Offline
Guido Lovelace
Product
Away
James Lovelace
People
Active
Ada Turing
Sales
Offline
Margaret Turing
Design
Away

Tree data#

Path-based hierarchy via getTreeDataPath. Expand groups on the first column.

Name
Role
Status
Engineering
Design
Product
Operations

Locale override#

Partial localeText map for toolbar and control labels.

Ada Lovelace
Engineering
Alan Lovelace
Design
Grace Lovelace
Product
Katherine Lovelace
Marketing
Linus Lovelace
Sales

Props API#

Full surface area — DataTable, columns, pagination, actions, classNames, styles, and localeText. Use these tables when wiring the package in another app.

DataTable#

Core props. Features stay opt-in unless noted.

DataTableProps

PropTypeDefaultDescription
dataT[]-Row data (full set in client mode, or current page in server mode).
columnsDataTableColumn<T>[]-Column definitions.
getRowId(row, index) => stringrow.idStable row id for selection, edit, and expand state.
showPaginationbooleantrueShow footer pagination.
pageSizenumber10Rows per page. Any positive number (e.g. 18).
paginationOptionsDataTablePaginationOptions-Page-size combobox, totals, numbered pages, min/max.
paginationMode'client' | 'server''client'Who owns paging. Wins over mode when both set.
mode'client' | 'server''client'Legacy alias for data sourcing (prefer paginationMode).
totalRowsnumber-Server-mode total row count.
loadingbooleanfalseLoading overlay over the scroll area.
onStateChange(state) => void-Fires when page, sort, filters, density, etc. change.
selectablebooleanfalseCheckbox selection column.
selectedIdsstring[]-Controlled selection.
defaultSelectedIdsstring[]-Uncontrolled initial selection.
onSelectionChange(ids) => void-Selection callback.
snbooleantrueAuto serial-number column (not in row data).
snHeaderstring"SN"SN column header label.
stickyHeaderbooleanfalsePin header while scrolling body.
stickyHeadingbooleanfalseDeprecated alias for stickyHeader.
stickyFirstColumnbooleanfalsePin first data column horizontally.
minTableWidthstring-Min table width before horizontal scroll.
maxHeightstring-Scroll container max-height (defaults to 28rem with sticky/virtualization).
emptyMessagestringlocaleEmpty state text (falls back to localeText.emptyMessage).
enableMultiSortbooleantrueAllow multiple sort columns.
sortDataTableSort[]-Controlled sort.
defaultSortDataTableSort[][]Uncontrolled initial sort.
onSortChange(sort) => void-Sort change callback.
enableFilteringbooleanfalsePer-column filter bar.
filtersDataTableFilters-Controlled filter bar values.
defaultFiltersDataTableFilters-Uncontrolled initial filters.
onFiltersChange(filters) => void-Filter bar callback.
showFilterBuilderbooleanfalseAdvanced multi-condition filter popover.
advancedFiltersFilterCondition[]-Controlled advanced filters.
onFilterBuilderApply(payload) => void-Called when builder Apply is pressed.
enableQuickFilterbooleanfalseGlobal toolbar search.
quickFilterstring-Controlled quick filter.
onQuickFilterChange(value) => void-Quick filter callback.
quickFilterPlaceholderstring-Overrides locale quick-filter placeholder.
showColumnSelectorbooleanfalseColumns show/hide menu.
columnVisibilityRecord<string, boolean>-Visibility map (false = hidden).
onColumnVisibilityChange(v) => void-Visibility callback.
reorderablebooleanfalseDrag headers to reorder.
columnOrderstring[]-Controlled column order.
onColumnOrderChange(order) => void-Order callback.
showColumnMenubooleanfalsePer-header ⋮ menu (sort / pin / hide).
pinnedColumns{ left?, right? }-Pinned column keys.
onPinnedColumnsChange(pinned) => void-Pin change callback.
resizablebooleanfalseDrag column edges to resize.
columnWidthsRecord<string, number>-Controlled widths.
onColumnWidthsChange(widths) => void-Width callback.
density'compact'|'comfortable'|'spacious''compact'Row density.
showDensityControlbooleanfalseToolbar density menu.
activeRowIdstring | null-Highlighted row id.
onRowClick(row, index) => void-Row click handler.
rowClassNamestring | (row, index) => string-Per-row class helper.
actionsDataTableRowAction[] | (row) => …-Declarative row actions.
actionsDisplay'menu' | 'icons''menu'Shorthand for actionsOptions.display.
actionsOptionsDataTableActionsOptions-Permissions, sticky, display mode.
renderRowActions(row) => ReactNode-Custom actions content (ignored if actions is set).
popoverOffsetnumber8floating-ui offset for menus.
popoverPlacementPlacementbottom-startfloating-ui placement.
editablebooleanfalseEnable inline editing.
editMode'cell' | 'row''cell'Single cell vs whole-row draft.
editAllColumnsbooleanfalseAll columns editable unless column.editable === false.
processRowUpdate(newRow, oldRow) => T | Promise<T>-Commit edited row.
onProcessRowUpdateError(error) => void-Edit commit error handler.
onCellEditStart(params) => void-Fired when edit begins.
onCellEditStop(params) => void-Fired when edit ends.
isCellEditable(params) => boolean-Per-cell edit gate.
enableVirtualizationbooleanfalseRow virtualization (off with tree/detail).
virtualRowHeightnumber-Estimated row height; defaults from density.
virtualOverscannumber8Extra rows outside viewport.
showExportbooleanfalseCSV export toolbar.
exportFilenamestringtable-export.csvDownload filename.
exportScope'filtered' | 'page' | 'selected''filtered'Which rows are exported.
onExported(format) => void-After export completes (csv | clipboard).
enableKeyboardNavigationbooleanfalseArrow-key focus; Enter starts edit.
getDetailPanelContent(params) => ReactNode-Master-detail panel under a row.
detailPanelExpandedRowIdsstring[]-Controlled detail expand state.
onDetailPanelExpandedRowIdsChange(ids) => void-Detail expand callback.
treeDatabooleanfalseEnable path-based tree hierarchy.
getTreeDataPath(row) => string[]-Path segments for each row.
expandedTreeIdsstring[]-Controlled tree expand ids.
defaultGroupingExpansionDepthnumber-Initial expand depth (-1 = all).
groupingColDef{ headerName?, width?, … }-Grouping column chrome.
localeTextPartial<DataTableLocaleText>-Override UI strings (see localeText table).
radius'none'|'xs'|'sm'|'md''xs'Corner radius token.
showRowBordersbooleantrueHorizontal borders between rows.
showColumnBordersbooleanfalseVertical borders between columns.
classNamestring-Root element class.
styleCSSProperties-Root element inline style.
classNamesDataTableClassNames-Per-slot Tailwind classes (see classNames slots).
stylesDataTableStyles-Per-slot inline CSS (see styles slots).
toolbarReactNode-Extra toolbar content beside built-ins.

DataTableColumn#

Per-column configuration passed in columns[].

DataTableColumn<T>

PropTypeDefaultDescription
keystring-Field key on the row object.
headerstring-Header label.
sortableboolean-Include in sort cycling.
hideBelow'sm' | 'md' | 'lg'-Hide column below breakpoint.
wrapboolean-Soft-wrap cell text (disables truncate).
truncatebooleantrue*Ellipsis overflow (*default when wrap is unset).
stickyboolean-Legacy sticky left; prefer pinned.
pinned'left' | 'right'-Pin while scrolling horizontally.
resizablebooleantrueAllow resize when table resizable is on.
widthnumber-Preferred width in px.
minWidthnumber-Minimum width in px.
maxWidthnumber-Maximum width in px.
filterableboolean-Appear in filter bar / builder.
filterTypestring | enum | number | …-Filter input type.
filterOptionsstring[]-Enum / select options for filter.
filterMinnumber-Numeric filter min.
filterMaxnumber-Numeric filter max.
filterStepnumber-Numeric filter step.
editableboolean-Editable when table editable is on.
editType'text'|'number'|'select'|'boolean'|'textarea''text'Built-in editor.
editOptionsstring[]-Select options for editType select.
renderEditCell(helpers) => ReactNode-Custom editor.
cell(row, index) => ReactNode-Custom display renderer.
classNamestring-Body cell classes.
headerClassNamestring-Header cell classes.

paginationOptions#

Footer rows-per-page combobox (type + dropdown) and pager chrome.

DataTablePaginationOptions

PropTypeDefaultDescription
showPageSizeOptionsbooleantrueShow rows-per-page combobox.
pageSizeOptionsnumber[][5,10,20,50]Preset sizes; current pageSize always merged in.
allowCustomPageSizebooleantrueType a custom limit in the same control.
minPageSizenumber1Clamp typed values (min).
maxPageSizenumber500Clamp typed values (max).
showPageNumbersbooleantrueNumbered page buttons.
maxVisiblePagesnumber3Sliding window of page numbers.
showTotalbooleantrueShowing X–Y of Z.
rowsLabelstring"Rows"Label beside page-size control.
showPrevNextbooleantruePrevious / next buttons.

actions & actionsOptions#

Declarative row actions — menu or icons, never both.

DataTableRowAction

PropTypeDefaultDescription
idstring-Optional action id.
labelstring-Menu / tooltip label.
onClick(row) => void-Click handler.
iconReactNode-Icon for menu or icons mode.
variant'default' | 'destructive'-Destructive styling for delete-like actions.
showboolean | (row) => boolean-Conditional visibility (prefer over hidden).
hiddenboolean | (row) => boolean-Hide when true.
disabledboolean | (row) => boolean-Disable per row.
permissionstring | (row) => boolean-Checked via actionsOptions.permissions / canAccess.

DataTableActionsOptions

PropTypeDefaultDescription
display'menu' | 'icons''menu'⋯ popover or icon buttons only (never both).
permissionsstring[] | Record<string, boolean>-Allowed permission keys.
canAccess(permission, row) => boolean-Custom permission check (wins).
stickybooleantrueSticky actions column.
menuAriaLabelstring-Aria label for ⋯ trigger.

classNames slots#

Pass Tailwind (or any) class strings per slot. Merged last via tailwind-merge — same idea as MUI DataGrid classes.

DataTableClassNames

PropTypeDefaultDescription
rootstring-Outer DataTable wrapper.
toolbarstring-Top toolbar row.
quickFilterstring-Quick filter control.
columnSelectorstring-Columns visibility menu.
densityControlstring-Density menu.
exportstring-Export menu.
filterBuilderstring-Advanced filter builder trigger/popover.
filterBarstring-Per-column filter bar.
scrollstring-Scroll container around the table.
tablestring-<table> element.
headerstring-<thead> region.
headerRowstring-Header <tr>.
headerCellstring-Header <th> cells.
bodystring-<tbody>.
rowstring-Body <tr>.
cellstring-Body <td> cells.
paginationstring-Footer pagination.
loadingstring-Loading overlay.
emptystring-Empty-state cell.
detailPanelstring-Expanded detail panel cell.
expandCellstring-Expand/collapse control cell.
checkboxCellstring-Selection checkbox cell.
snCellstring-Serial-number cell.
actionsCellstring-Row actions cell.
actionsHeaderstring-Actions column header.
classNames={{
  root: "shadow-sm",
  headerCell: "text-xs uppercase tracking-wide",
  row: "hover:bg-muted/40",
  pagination: "border-t",
}}

styles slots#

Per-slot React.CSSProperties. Prefer classNames for theme tokens; use styles for one-off layout.

DataTableStyles

PropTypeDefaultDescription
rootCSSProperties-Outer wrapper.
toolbarCSSProperties-Toolbar.
filterBarCSSProperties-Filter bar.
scrollCSSProperties-Scroll container.
tableCSSProperties-<table>.
headerCSSProperties-Header region.
headerRowCSSProperties-Header row.
headerCellCSSProperties-Header cells.
bodyCSSProperties-Body.
rowCSSProperties-Body rows.
cellCSSProperties-Body cells (merged after size/pin styles).
paginationCSSProperties-Footer.
loadingCSSProperties-Loading overlay.
emptyCSSProperties-Empty state.
detailPanelCSSProperties-Detail panel.
styles={{
  root: { borderRadius: 10 },
  scroll: { maxHeight: "22rem" },
  headerCell: { letterSpacing: "0.02em" },
}}

localeText#

Partial map over DataTableLocaleText. Unset keys keep English defaults from DEFAULT_LOCALE_TEXT.

Partial<DataTableLocaleText>

PropTypeDefaultDescription
emptyMessagestring"No results."Empty table copy.
loadingstring"Loading…"Loading overlay text.
snHeaderstring"SN"SN column header.
actionsHeaderstring"Actions"Actions column header.
quickFilterPlaceholderstring"Search…"Quick filter placeholder.
quickFilterAriaLabelstring-Quick filter aria-label.
quickFilterClearstring-Clear search button label.
densityLabelstring-Density control label.
densityCompact / Comfortable / Spaciousstring-Density option labels.
columnsLabelstring-Columns menu trigger.
columnsSearchPlaceholderstring-Columns search field.
columnsShowAll / columnsHideAllstring-Bulk visibility actions.
columnsCount(n) => string-Visible column count text.
exportLabelstring-Export menu trigger.
exportDownloadCsv / exportCopyCsv / exportCopiedstring-Export menu items + toast.
paginationShowing / paginationOfstring-“Showing X–Y of Z” parts.
paginationRowsLabelstring-Rows label (also overridable via paginationOptions).
paginationPrevious / paginationNextstring-Pager buttons.
paginationPageAria(n) => string-Page button aria.
filterBuilderLabelstring-Filter builder trigger.
filterBarAll / filterBarClearstring-Filter bar chrome.
filterBarPlaceholder / filterBarAria(header) => string-Per-column filter labels.
columnMenuSortAsc / SortDesc / ClearSortstring-Header menu sort items.
columnMenuPinLeft / PinRight / Unpin / Hidestring-Header menu pin/hide.
selectAllAria / selectRowAriastring | fn-Selection aria.
expandRowAria / collapseRowAriastring-Detail expand aria.
expandGroupAria / collapseGroupAriastring-Tree group aria.
detailPanelAriastring-Detail panel region aria.

CSS & theming#

Import package CSS once, then override via classNames / styles. Consumer classes win.

<DataTable
  classNames={{
    root: "border-border",
    header: "bg-muted/40",
    row: "hover:bg-muted/30",
    pagination: "bg-card",
  }}
  styles={{
    root: { borderRadius: 12 },
    headerCell: { fontWeight: 600 },
  }}
  data={rows}
  columns={columns}
/>

Merge order

Internal classes → classNames.* (via tailwind-merge) → styles.* inline. Column className / headerClassName apply on that column’s cells.

Feature map#

Capability → prop. Everything here is opt-in except SN and pagination.

Quick reference

PropTypeDefaultDescription
Auto SNsntrueComputed serial column
SelectionselectablefalseCheckbox column
Quick filterenableQuickFilterfalseToolbar search
Filter barenableFilteringfalsePer-column filters
Filter buildershowFilterBuilderfalseAdvanced filters
Export CSVshowExportfalseDownload / copy
EditingeditablefalseCell or row mode
Detail panelgetDetailPanelContentExpandable rows
Tree datatreeData + getTreeDataPathfalseHierarchy
VirtualizationenableVirtualizationfalseLarge pages
KeyboardenableKeyboardNavigationfalseArrow focus
i18nlocaleTextUI string map
Custom CSSclassNames / stylesPer-slot styling