Documentation · itzsa

Table

Composable DataTable for React — pagination, selection, sorting, filters, editing, 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 from this docs app. Data and serializable props live under src/app/table/data and props/.

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
<DataTable
  treeData
  getTreeDataPath={(row) => row.path}
  defaultGroupingExpansionDepth={1}
  groupingColDef={{ headerName: "Org / name" }}
  data={rows}
  columns={columns}
/>

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).
paginationOptionsDataTablePaginationOptionsPage-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).
totalRowsnumberServer-mode total row count.
loadingbooleanfalseLoading overlay over the scroll area.
onStateChange(state) => voidFires when page, sort, filters, density, etc. change.
selectablebooleanfalseCheckbox selection column.
selectedIdsstring[]Controlled selection.
defaultSelectedIdsstring[]Uncontrolled initial selection.
onSelectionChange(ids) => voidSelection 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.
minTableWidthstringMin table width before horizontal scroll.
maxHeightstringScroll 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) => voidSort change callback.
enableFilteringbooleanfalsePer-column filter bar.
filtersDataTableFiltersControlled filter bar values.
defaultFiltersDataTableFiltersUncontrolled initial filters.
onFiltersChange(filters) => voidFilter bar callback.
showFilterBuilderbooleanfalseAdvanced multi-condition filter popover.
advancedFiltersFilterCondition[]Controlled advanced filters.
onFilterBuilderApply(payload) => voidCalled when builder Apply is pressed.
enableQuickFilterbooleanfalseGlobal toolbar search.
quickFilterstringControlled quick filter.
onQuickFilterChange(value) => voidQuick filter callback.
quickFilterPlaceholderstringOverrides locale quick-filter placeholder.
showColumnSelectorbooleanfalseColumns show/hide menu.
columnVisibilityRecord<string, boolean>Visibility map (false = hidden).
onColumnVisibilityChange(v) => voidVisibility callback.
reorderablebooleanfalseDrag headers to reorder.
columnOrderstring[]Controlled column order.
onColumnOrderChange(order) => voidOrder callback.
showColumnMenubooleanfalsePer-header ⋮ menu (sort / pin / hide).
pinnedColumns{ left?, right? }Pinned column keys.
onPinnedColumnsChange(pinned) => voidPin change callback.
resizablebooleanfalseDrag column edges to resize.
columnWidthsRecord<string, number>Controlled widths.
onColumnWidthsChange(widths) => voidWidth callback.
density'compact'|'comfortable'|'spacious''compact'Row density.
showDensityControlbooleanfalseToolbar density menu.
activeRowIdstring | nullHighlighted row id.
onRowClick(row, index) => voidRow click handler.
rowClassNamestring | (row, index) => stringPer-row class helper.
actionsDataTableRowAction[] | (row) => …Declarative row actions.
actionsDisplay'menu' | 'icons''menu'Shorthand for actionsOptions.display.
actionsOptionsDataTableActionsOptionsPermissions, sticky, display mode.
renderRowActions(row) => ReactNodeCustom 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) => voidEdit commit error handler.
onCellEditStart(params) => voidFired when edit begins.
onCellEditStop(params) => voidFired when edit ends.
isCellEditable(params) => booleanPer-cell edit gate.
enableVirtualizationbooleanfalseRow virtualization (off with tree/detail).
virtualRowHeightnumberEstimated 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) => voidAfter export completes (csv | clipboard).
enableKeyboardNavigationbooleanfalseArrow-key focus; Enter starts edit.
getDetailPanelContent(params) => ReactNodeMaster-detail panel under a row.
detailPanelExpandedRowIdsstring[]Controlled detail expand state.
onDetailPanelExpandedRowIdsChange(ids) => voidDetail expand callback.
treeDatabooleanfalseEnable path-based tree hierarchy.
getTreeDataPath(row) => string[]Path segments for each row.
expandedTreeIdsstring[]Controlled tree expand ids.
defaultGroupingExpansionDepthnumberInitial 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.
classNamestringRoot element class.
styleCSSPropertiesRoot element inline style.
classNamesDataTableClassNamesPer-slot Tailwind classes (see classNames slots).
stylesDataTableStylesPer-slot inline CSS (see styles slots).
toolbarReactNodeExtra toolbar content beside built-ins.

DataTableColumn#

Per-column configuration passed in columns[].

DataTableColumn<T>

PropTypeDefaultDescription
keystringField key on the row object.
headerstringHeader label.
sortablebooleanInclude in sort cycling.
hideBelow'sm' | 'md' | 'lg'Hide column below breakpoint.
wrapbooleanSoft-wrap cell text (disables truncate).
truncatebooleantrue*Ellipsis overflow (*default when wrap is unset).
stickybooleanLegacy sticky left; prefer pinned.
pinned'left' | 'right'Pin while scrolling horizontally.
resizablebooleantrueAllow resize when table resizable is on.
widthnumberPreferred width in px.
minWidthnumberMinimum width in px.
maxWidthnumberMaximum width in px.
filterablebooleanAppear in filter bar / builder.
filterTypestring | enum | number | …Filter input type.
filterOptionsstring[]Enum / select options for filter.
filterMinnumberNumeric filter min.
filterMaxnumberNumeric filter max.
filterStepnumberNumeric filter step.
editablebooleanEditable when table editable is on.
editType'text'|'number'|'select'|'boolean'|'textarea''text'Built-in editor.
editOptionsstring[]Select options for editType select.
renderEditCell(helpers) => ReactNodeCustom editor.
cell(row, index) => ReactNodeCustom display renderer.
classNamestringBody cell classes.
headerClassNamestringHeader 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
idstringOptional action id.
labelstringMenu / tooltip label.
onClick(row) => voidClick handler.
iconReactNodeIcon for menu or icons mode.
variant'default' | 'destructive'Destructive styling for delete-like actions.
showboolean | (row) => booleanConditional visibility (prefer over hidden).
hiddenboolean | (row) => booleanHide when true.
disabledboolean | (row) => booleanDisable per row.
permissionstring | (row) => booleanChecked 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) => booleanCustom permission check (wins).
stickybooleantrueSticky actions column.
menuAriaLabelstringAria 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
rootstringOuter DataTable wrapper.
toolbarstringTop toolbar row.
quickFilterstringQuick filter control.
columnSelectorstringColumns visibility menu.
densityControlstringDensity menu.
exportstringExport menu.
filterBuilderstringAdvanced filter builder trigger/popover.
filterBarstringPer-column filter bar.
scrollstringScroll container around the table.
tablestring<table> element.
headerstring<thead> region.
headerRowstringHeader <tr>.
headerCellstringHeader <th> cells.
bodystring<tbody>.
rowstringBody <tr>.
cellstringBody <td> cells.
paginationstringFooter pagination.
loadingstringLoading overlay.
emptystringEmpty-state cell.
detailPanelstringExpanded detail panel cell.
expandCellstringExpand/collapse control cell.
checkboxCellstringSelection checkbox cell.
snCellstringSerial-number cell.
actionsCellstringRow actions cell.
actionsHeaderstringActions 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
rootCSSPropertiesOuter wrapper.
toolbarCSSPropertiesToolbar.
filterBarCSSPropertiesFilter bar.
scrollCSSPropertiesScroll container.
tableCSSProperties<table>.
headerCSSPropertiesHeader region.
headerRowCSSPropertiesHeader row.
headerCellCSSPropertiesHeader cells.
bodyCSSPropertiesBody.
rowCSSPropertiesBody rows.
cellCSSPropertiesBody cells (merged after size/pin styles).
paginationCSSPropertiesFooter.
loadingCSSPropertiesLoading overlay.
emptyCSSPropertiesEmpty state.
detailPanelCSSPropertiesDetail 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.
quickFilterAriaLabelstringQuick filter aria-label.
quickFilterClearstringClear search button label.
densityLabelstringDensity control label.
densityCompact / Comfortable / SpaciousstringDensity option labels.
columnsLabelstringColumns menu trigger.
columnsSearchPlaceholderstringColumns search field.
columnsShowAll / columnsHideAllstringBulk visibility actions.
columnsCount(n) => stringVisible column count text.
exportLabelstringExport menu trigger.
exportDownloadCsv / exportCopyCsv / exportCopiedstringExport menu items + toast.
paginationShowing / paginationOfstring“Showing X–Y of Z” parts.
paginationRowsLabelstringRows label (also overridable via paginationOptions).
paginationPrevious / paginationNextstringPager buttons.
paginationPageAria(n) => stringPage button aria.
filterBuilderLabelstringFilter builder trigger.
filterBarAll / filterBarClearstringFilter bar chrome.
filterBarPlaceholder / filterBarAria(header) => stringPer-column filter labels.
columnMenuSortAsc / SortDesc / ClearSortstringHeader menu sort items.
columnMenuPinLeft / PinRight / Unpin / HidestringHeader menu pin/hide.
selectAllAria / selectRowAriastring | fnSelection aria.
expandRowAria / collapseRowAriastringDetail expand aria.
expandGroupAria / collapseGroupAriastringTree group aria.
detailPanelAriastringDetail 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