Skip to content

React Data Table

A typed, accessible React data table on TanStack Table v9 with search, faceted filters, multi-sort, pagination, selection and CSV export, all in glass.

npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/data-table.json
Open deals
Stage
Northwind
Proposal4200
Acme Corp
Won9800
Globex
Lead1500
Initech
Won6400
Umbrella
Proposal3100
Sorts the table. Shift-click, or press Shift+Enter, to sort by more than one column.
  • DataTable
  • UserCell
  • Highlight
  • StatusCell
  • CurrencyCell
  • +10 more
  • +7 more

Files to copy

17 folders · 25 files · 5 packages
From theme/src/
  • components/data-table/
  • components/pagination/
  • components/alert/
  • components/avatar/
  • components/badge/
  • components/button/
  • components/checkbox/
  • components/drawer/parts/sheet.tsx
  • components/input/
  • components/progress/
  • components/select/
  • components/spinner/
  • components/status-icons/
  • hooks/{use-controllable.ts, use-direction.ts, use-latest.ts, use-magnetic.ts, use-media-query.ts, use-preferences.ts, use-virtual-window.ts}
  • motion/{gate.ts, reorder.tsx, tokens.ts}
  • lib/{cn.ts, csv.ts, field-control-shell.tsx, field-size.ts, form.ts, glide-highlight.tsx, group-segments.ts, initials.ts, motion-props.ts, page-size.ts, popup-a11y.ts, popup-motion.ts, state-light.tsx, warn-once.ts}
  • styles/
shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/data-table.jsonRegistry item: data-table. The styles need the Tailwind v4 glass UI setup.
Packages
pnpm add @base-ui/react @tanstack/react-table clsx motion tailwind-merge

312 generated users. Search highlights matches, filters show counts, shift-click headers to sort by several columns, shift-click checkboxes to select a range. Selection survives paging. Under 640px the rows become cards.

Workspace members
DetailsActions
Asha Kapoorasha.kapoor@example.com
BillingPast dueEnterprise$998
Usage for Asha Kapoor
x
Chloe Bosechloe.bose@example.com
ViewerActiveStarter$203
Usage for Chloe Bose
x
Sara Tanakasara.tanaka189@example.com
ViewerTrialStarter$232
Usage for Sara Tanaka
x
Tara Dastara.das84@example.com
ViewerChurnedStarter$0
Usage for Tara Das
x
Neha Silvaneha.silva@example.com
EditorActivePro$1,089
Usage for Neha Silva
x
Meera Vermameera.verma@example.com
BillingPast dueStarter$261
Usage for Meera Verma
x
Ananya Raoananya.rao@example.com
ViewerPast dueStarter$87
Usage for Ananya Rao
x
Tara Kumartara.kumar@example.com
ViewerActiveStarter$87
Usage for Tara Kumar
x
Chloe Daschloe.das@example.com
BillingActivePro$198
Usage for Chloe Das
x
Noah Guptanoah.gupta63@example.com
AdminActiveStarter$319
Usage for Noah Gupta
x
Rows per page

Showing 1–10 of 312

Go to page
Sorts the table. Shift-click, or press Shift+Enter, to sort by more than one column.

Server-side

manual + rowCount: the table only renders. Sorting, search (debounced), filters and paging go to a fake API that answers after 600ms. While it loads, the previous rows stay in place under a veil, so nothing jumps.

Minimal

Just data, columns and a caption. Search, sorting, export and the View menu come with sensible defaults; turn any of them off with a prop.

Animated sort

Click a column header: rows slide to their new place (transform only, spring.smooth) instead of swapping. It is on by default (animateRows) and instant with reduced motion. For any other list, AnimatedList and AnimatedListItem do the same on insert, remove and reorder.

Loading and error states

While the first request runs the table shows skeleton rows with a sweep of light and a progress bar under the header. When it fails, an inline alert with a Retry button replaces the body (rows that were already on screen stay under a veil, with the alert below them).

Ten thousand rows

With maxHeight set, a page of 50 rows or more renders only the rows in view plus a few more (virtualize defaults to auto; pass virtualize to force it). Scroll to the end: the count below stays small, yet the scrollbar spans all 10,000. Rows outside the window are not in the DOM, so Tab skips them: set virtualize={false} for a table people tab through row by row.

Pagination on its own

A nav landmark with aria-current on the current page. The number of slots stays the same as you page, so buttons never jump under the pointer; on phones it collapses to “Page x of y”.

Keyboard

KeysAction
Tab/Shift + TabMove through the toolbar, sortable headers, row checkboxes, row menus and the pager. A table that overflows becomes a focusable, scrollable region.
Enter/SpaceOn a sortable header: sort by that column. On a checkbox or button: press it.
Shift + Enter (or Shift-click)On a sortable header: add the column to a multi-sort.
Shift-clickOn a row checkbox: select the range from the last one.
EscapeIn the search box: clear the search.
Arrow keys, Home/End, typeaheadIn the row, view and filter menus: move between items. Enter runs one; Escape closes the menu.

Accessibility

  • Semantic table: a caption, column headers with scope, aria-sort on the primary sorted column. Secondary sorts are read out on their header buttons.
  • Sortable headers are buttons; Shift + Enter (or Shift-click) adds a column to the sort. A plain click on a column of a multi-sort makes it the only sort. Escape clears the search box.
  • Checkboxes are named after their row (“Select row Ravi Kumar”); Shift-click selects a range.
  • One polite live region announces result counts, sorting, page and page-size changes, and selection.
  • Search ignores case and accents (“cafe” finds “Café”) and only looks at visible columns, so every match is marked.
  • Focus never drops to the page: clearing the search, removing a filter chip, clearing the selection or deleting rows moves it to the next sensible control. Focused cells are kept clear of the sticky header, the pinned columns and the selection bar.
  • The scroll area is focusable (and a named region) when it overflows, so it can be scrolled with arrow keys. Focus outlines are solid; touch targets are 44px; forced-colors mode is supported.

DataTable props

PropTypeDefaultDescription
data (required)TData[]NoneThe rows. With server-side mode, only the current page.
columns (required)DataTableColumn<TData>[]NoneColumn definitions; see DataTableColumn.
getRowId((row: TData, index: number) => string)row.id when present, otherwise the indexReturns a stable id for a row; it is the row's React key and keys the selection and expansion state.
getRowLabel((row: TData) => string)the first column's valueShort name for a row, used in labels ("Select row Ravi Kumar").
caption (required)stringNoneTable caption: names the table for screen readers.
showCaptionbooleanfalseShow the caption visually (it is visually hidden by default).
idstringNoneSets the id of the table element.
aria-labelstringlabels.scrollRegion(caption)Accessible name of the scroll region (a landmark only while the table overflows).
classNamestringNoneClass for the outer wrapper (toolbar + table + footer).
tableClassNamestringNoneClass for the glass panel around the table.
enableSearchbooleantrueShows a search box that filters every column.
searchDebounceMsnumber200Delay in ms before typing in the search box filters the rows.
enableSelectionbooleanfalseCheckbox column, select-all and the bulk-actions bar.
enableViewOptionsbooleantrueAdds column visibility and density options to a View menu.
enableExportbooleantrueShows a button that exports the rows as CSV.
exportFilenamestring"data"File name of the CSV download (".csv" is added).
onExport((rows: TData[], scope: "filtered" | "selected") => void)NoneReplace the built-in CSV download. Receives the rows being exported, in table order. With manual pagination the table only holds the current page, so the toolbar Export is shown only when this is set: fetch the full export from your server here.
enableSortingbooleantrueLets people sort by clicking a column header; set false to turn sorting off for the whole table.
enableMultiSortbooleantrueShift-click headers to sort by more than one column.
stickyFirstColumnbooleantruePin the first data column (and the checkbox / expand columns) while scrolling sideways. Under 640px the pinned columns are capped at about 45% of the screen.
animateRowsbooleantrueSlide rows to their new place when sorting, filtering or paging reorders them (Motion layout, transform only, spring.smooth; rows are measured once per change). Instant with reduced motion.
virtualizeboolean | "auto""auto"Render only the rows in view (plus a few more) with spacers for the rest, so a long page (100 rows) sorts and scrolls without a long task. "auto" windows a page of 50 rows or more when maxHeight is set and the layout is the table (not cards). Rows are measured as they render, expanded panels included. Rows outside the window are not in the DOM, so Tab skips them and a focused row that scrolls out loses focus: set false for tables people tab through row by row.
maxHeightstringNoneMax height of the scroll area; the header sticks to its top.
pageSizeOptionsnumber[][10, 20, 50, 100]Page sizes offered in the footer.
defaultPageSizenumber10Sets the starting page size when uncontrolled.
hidePaginationbooleanfalseHide the footer (pagination).
rowActionsDataTableRowAction<TData>[] | ((row: TData) => DataTableRowAction<TData>[])NoneItems of the ⋯ menu at the end of each row: a list, or a function that returns one for a row.
renderExpanded((row: TData) => ReactNode)NoneDetail panel shown under an expanded row. Enables the chevron column.
bulkActionsDataTableBulkAction<TData>[][]Shows the buttons in the floating selection bar.
toolbarLeftReactNodeNoneExtra controls at the start / end of the toolbar.
toolbarRightReactNodeNoneExtra controls at the end of the toolbar.
mobileLayout"scroll" | "cards""scroll""cards": rows become glass cards under 640px.
loadingbooleanfalseFirst load (skeleton) or, when rows are present, a refetch (rows stay, dimmed).
errorReactNodeNoneShows an error message (or true for the default).
onRetry(() => void)NoneCalled by the error state's Retry button. Without it the button is hidden.
emptyStateReactNodeNoneCustom empty state (replaces the default).
densityDataTableDensityNoneRow height, controlled: "comfortable" or "compact". Pair with onDensityChange; the View menu changes it.
defaultDensityDataTableDensity"comfortable"Sets the starting density when uncontrolled.
onDensityChange((density: DataTableDensity) => void)NoneCalled with the new density from the View menu.
sortingDataTableSortingNoneCurrent sort order, as an array of column id and direction; pass it with onSortingChange to control sorting.
defaultSortingDataTableSortingNoneSets the starting sorting when uncontrolled.
onSortingChange((sorting: DataTableSorting) => void)NoneCalled with the next sorting.
paginationDataTablePaginationNoneSets the page index and size when controlled.
onPaginationChange((pagination: DataTablePagination) => void)NoneCalled with the next page index and size.
globalFilterstringNoneCurrent search text; pass it with onGlobalFilterChange to control the search box.
defaultGlobalFilterstringNoneInitial search text when uncontrolled (a pre-filled search box).
onGlobalFilterChange((value: string) => void)NoneCalled with the applied (debounced) search text.
columnFiltersDataTableColumnFiltersNoneCurrently applied faceted filters; pass it with onColumnFiltersChange to control them.
defaultColumnFiltersDataTableColumnFiltersNoneSets the starting faceted filters when uncontrolled.
onColumnFiltersChange((filters: DataTableColumnFilters) => void)NoneCalled with the next faceted filters.
rowSelectionDataTableRowSelectionNoneSelected row ids (controlled).
defaultRowSelectionDataTableRowSelectionNoneSets the row ids selected at first when uncontrolled ({ [rowId]: true }).
onRowSelectionChange((selection: DataTableRowSelection) => void)NoneCalled with the next selection.
columnVisibilityDataTableColumnVisibilityNoneWhich columns are shown, keyed by column id; pass it with onColumnVisibilityChange to control it.
onColumnVisibilityChange((visibility: DataTableColumnVisibility) => void)NoneCalled with the next visibility map.
manualbooleanfalseWorks as shorthand for manualPagination + manualSorting + manualFiltering.
manualPaginationbooleanNonedata is already the current page; use rowCount for the total.
manualSortingbooleanNonedata is already sorted.
manualFilteringbooleanNonedata is already searched and filtered.
rowCountnumberNoneSets the total rows on the server (manual pagination).
labelsPartial<DataTableLabels>defaultDataTableLabelsEvery other string, for translation: labels={{ searchLabel: "…" }}; omitted keys keep the English of defaultDataTableLabels. All 60 keys of DataTableLabels are listed in the key table under the props table.
DataTableLabels keys and English defaults (60)
Pass any key in labels; the rest keep the defaults of defaultDataTableLabels.
KeyEnglish default
searchLabelSearch
searchPlaceholderSearch…
clearSearchClear search
results(n) => (n === 0 ? "No results" : plural(n, "result", "results"))
clearFiltersClear filters
filterChipsLabelActive filters
removeFilter(column, value) => `Remove filter ${column}: ${value}`
filterSelected(column, count) => (count ? `Filter by ${column}, ${count} selected` : `Filter by ${column}`)
clearFilterClear filter
viewView
columnsColumns
densityDensity
comfortableComfortable
compactCompact
exportCsvExport
exportSelectedExport selected
sortBySort by
sortDefaultDefault order
sortOptionAsc(column) => `${column} (ascending)`
sortOptionDesc(column) => `${column} (descending)`
selectAllOnPageSelect all rows on this page
selectRow(row) => `Select row ${row}`
allOnPageSelected(n) => `All ${plural(n, "row", "rows")} on this page are selected.`
selectAllMatching(n) => `Select all ${plural(n, "row", "rows")}`
allSelected(n) => `All ${plural(n, "row", "rows")} are selected.`
clearSelectionClear selection
selectedCount(n) => `${n.toLocaleString()} selected`
hiddenSelected(n) => `${n.toLocaleString()} hidden by filters`
facetCount(n) => plural(n, "row", "rows")
bulkActionsSelection actions
rowActions(row) => `Actions for ${row}`
actionsColumnActions
expandColumnDetails
expandRow(row) => `Show details for ${row}`
collapseRow(row) => `Hide details for ${row}`
showDetailsShow details
hideDetailsHide details
sortHintSorts the table. Shift-click, or press Shift+Enter, to sort by more than one column.
sortAscendingascending
sortDescendingdescending
sortPriority(n) => `sort priority ${n}`
sortedBy(description) => `Sorted by ${description}`
sortClearedSorting removed
sortThenthen
rowsPerPageRows per page
showing(from, to, total) => total === 0 ? "No rows" : `Showing ${from.toLocaleString()}–${to.toLocaleString()} of ...
pageOf(page, count) => `Page ${page} of ${count}`
pageSizeChanged(size, page, count) => `${size} rows per page. Page ${page} of ${count}`
scrollRegion(caption) => `${caption}, scrollable`
goToPageGo to page
loadingLoading rows…
refreshingUpdating…
emptyNo data yet
emptyDescriptionRows will show up here once there is something to list.
emptyForQuery(query) => `No results for “${query}”`
emptyFilteredNo rows match these filters
emptyFilteredDescriptionTry a different search or remove a filter.
errorTitleCouldn’t load the data
retryRetry
paginationnested object: takes the keys of PaginationLabels; empty here, so its own English defaults apply

Column options

PropTypeDefaultDescription
idstringNoneUnique; also the accessor key unless accessorKey / accessorFn is set.
headerstringNoneHeader text; reused for the View menu, CSV, cards and announcements.
accessorKey / accessorFnkeyof TData / (row) => unknownidSets where the value comes from.
cell(ctx) => ReactNodetextCustom cell. ctx has row, value, highlight(), query, density.
align / numeric"left" | "center" | "right" / boolean"left"numeric right-aligns with tabular figures and sorts numerically.
width / minWidthnumber | stringNonePreferred and minimum width. For wrap columns, width is also the minimum.
enableSorting / enableHidingbooleantrueSwitches that turn sorting and hiding on or off for one column.
defaultHiddenbooleanfalseStarts hidden (show it from the View menu).
searchable / searchValueboolean / (row) => stringtrueWhether, and on what text, the global search matches. Hidden columns are never searched.
filter / filterOptions"faceted" / DataTableFilterOption[]NoneMulti-select filter with counts. Options are derived from the data when omitted.
sortFn"alphanumeric" | "text" | "basic" | "datetime" | (a, b) => numberby column typePicks how the column sorts: a built-in sort or your own comparison function.
exportValue / enableExport(row) => value / booleanvalue / trueControls what the CSV export writes for this column: the cell value, and whether it is included.
wrap / hideInCardsbooleanfalseLet text wrap / leave out of the card layout.

Pagination props

The pager under the table is the Pagination component. Its props (page, onPageChange, pageCount, siblingCount and the rest) are listed on its page.

Cell helpers

PropTypeDefaultDescription
UserCell{ name, email?, src?, highlight? }NoneShows an avatar, name and email.
StatusCell{ value, tones?, label? }NoneShows a badge with a tone per value.
ProgressCell{ value, label }NoneShows a thin progress bar with a percentage.
CurrencyCell / formatCurrency{ value, currency?, locale? }"USD"Formats the value as currency with tabular figures.
RelativeDateCell / formatRelativeDate{ value, now?, locale? }None“3 days ago”, full date in the title and for screen readers.
highlightText / Highlight(text, query)NoneWrap search matches in <mark>.
toCsv / exportCsv(headers, rows) / (filename, headers, rows)NoneRFC 4180 CSV with formula-injection guard and a UTF-8 BOM.

CurrencyCell props

PropTypeDefaultDescription
value (required)numberNoneThe amount, in major units (12.5 is 12.50).
currencystring"USD"Sets the ISO 4217 currency code, for example "USD".
localestringthe runtime's localeBCP 47 locale used to format the amount; defaults to the runtime's locale.
highlightHighlighter(t) => tHighlights the part of the formatted amount that matches the table's search text.

Highlight props

PropTypeDefaultDescription
text (required)string | number | null | undefinedNoneThe text to show. A number is shown as is; null or undefined renders nothing.
query (required)stringNoneThe search text to mark inside text, matched case-insensitively. An empty string marks nothing.

ProgressCell props

PropTypeDefaultDescription
value (required)numberNone0–100. Values outside the range are clamped.
label (required)stringNoneAccessible name of the bar, e.g. "Usage".
classNamestringNoneAdds extra classes to the cell.

RelativeDateCell props

PropTypeDefaultDescription
value (required)string | number | DateNoneThe moment to describe: a Date, an ISO string or a timestamp in ms.
nownumber | DateNoneThe reference time for "3 hours ago". Pass a fixed value on a prerendered page so the server and browser agree.
localestringthe runtime's localeBCP 47 locale for the relative phrase; defaults to the runtime's locale.

StatusCell props

PropTypeDefaultDescription
value (required)stringNoneThe status text from your data, e.g. "active".
tonesRecord<string, StatusTone>NoneTone per value, e.g. { active: "success", churned: "danger" }. Unknown values are neutral.
labelReactNodethe valueDisplay text (defaults to the value).
classNamestringNoneAdds extra classes to the badge.

UserCell props

PropTypeDefaultDescription
name (required)stringNoneThe person's full name; also the avatar's initials.
emailstringNoneShows the secondary line under the name.
srcstringNoneAvatar image URL; initials show without it.
status"online" | "away" | "offline"NoneShows the presence dot on the avatar.
highlightHighlighter(t) => tThe highlight function from the cell context, so search matches stay marked.
classNamestringNoneAdds extra classes to the cell.

All exports on this page

  • CurrencyCell — A money amount, right-aligned digits (tabular figures) formatted with Intl for the locale.
  • DataTable — A full data table: global search with highlighted matches, multi-column sorting, faceted filters, row selection with bulk actions.
  • Highlight — Highlight as a component: wraps every match of query in a <mark>, ignoring case and accents (the same matching as the table search).
  • ProgressCell — A small progress bar with the percentage beside it, for usage or completion columns.
  • RelativeDateCell — A date as relative text ("3 days ago", "in 2 hours") inside a <time>.
  • StatusCell — A status as a dotted Badge.
  • UserCell — A table cell for a person: avatar, name and an optional email.
  • defaultDataTableLabels — Default English strings of DataTableLabels; spread it and override single keys to reword.
  • foldText — Text as the search compares it: lower case, accents removed, ß → ss, … so "cafe" finds "Café".
  • formatCurrency — value as money in currency (default "USD") for locale (default: the browser's), with maximumFractionDigits decimals (default 0).
  • formatRelativeDate — "3 days ago", "in 2 hours".
  • highlightText — Wrap every match of query in a <mark>.

When to use the data table

  • Use DataTable as a React table with filters and pagination for an admin list of users or orders where people need search with highlighted matches, multi-column sorting and a faceted Status filter with counts. If you are looking for a shadcn data table alternative, this one comes with sorting, paging, selection and a caption in a single component.
  • Use enableSelection with bulkActions for a list where people pick rows across several pages and then export, archive or delete them from the floating selection bar.
  • Use manual with rowCount and the controlled sorting, pagination and filter props when the dataset lives on a server and only the current page is in memory.
  • Skip it when you only need a few static rows or a key value layout. A plain table, DescriptionList or a stack of GlassCard items is lighter and easier to scan.
  • Pair it with the Pagination component it already uses in its footer, Badge, Avatar and Progress through the StatusCell, UserCell and ProgressCell helpers, and Toast to confirm a bulk action or a finished CSV export.

SheenUI DataTable or the shadcn data table recipe?

The shadcn/ui data table is a recipe: you assemble columns, filters and pagination around TanStack Table yourself. SheenUI's DataTable is a finished component on TanStack Table v9: you pass data, columns and a caption and get search, faceted filters, multi-sort, pagination, row selection with bulk actions and a server mode through manual. Choose the recipe for full control of every cell; choose this one to skip the wiring.

Frequently asked questions

67 components pages in all: browse them on All components.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .