Data

Data table.

Search, sort and page through a small dataset.

LIVE PREVIEWTry it. It works.

Install the source

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/table.json

Registry setup · Examples · API and behavior · Open the playground

COMPLETE EXAMPLES

Use it in context.

Each example includes its imports, data and state. The preview runs that same source. Include the stylesheet once in your application.

Sort and search a small local list

The complete source includes its row type, data, columns and text search function.

Loads this example when you need it.

Keyboard

  • Tab reaches search, sort headings and page controls.
  • Enter toggles a sortable column.

States covered

  • Rows
  • Sorted
  • Filtered
  • Empty results

Install this complete example and its component dependencies.

Terminal
npx shadcn@latest add https://ui.bld8.dev/r/example-basic-table.json
Complete source
React / TypeScript
/*!
MIT License

Copyright (c) 2026 Jaison

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
'use client';
import {DataTable,type Column} from '@bld8/ui';
import '@bld8/ui/styles.css';
type Row={id:string;name:string;tasks:number};
const rows:Row[]=[{id:'one',name:'Example interface review',tasks:3},{id:'two',name:'Example notes',tasks:5},{id:'three',name:'Example reference library',tasks:2}];
const columns:Column<Row>[]=[{key:'name',header:'Project',cell:row=>row.name,sortValue:row=>row.name},{key:'tasks',header:'Tasks',cell:row=>row.tasks,sortValue:row=>row.tasks,align:'end'}];
export default function TableExample(){return <DataTable caption="Example project list" rows={rows} columns={columns} rowKey={row=>row.id} searchText={row=>row.name} pageSize={2}/>;}

Quick reference

React / TypeScript
<DataTable caption="Projects" rows={projects} columns={columns} rowKey={row => row.id} searchText={row => row.name} pageSize={5} />

In the workspace or ZIP starter, import components from @bld8/ui and include @bld8/ui/styles.css once. Registry installations use your local bld8/ source path. Wrap overlays in UIProvider.

API & behaviour

Try column ordering and row-save recovery · Saved layout guide

Generic over row type. Column<T>: key, header, cell(row), optional sortValue(row). Client-side filtering, sorting and pagination are included. Use server pagination for remote datasets, or WindowedTable with an explicit complete supplied dataset. grouping and collapsedGroupKeys add labelled grouped pages without changing the default table.

DataTable

DataTable public properties
PropTypeDefault
captionRequiredstring—
columnsRequiredColumn<T>[]—
rowKeyRequired(row: T) => string—
rowsRequiredT[]—
collapsedGroupKeysstring[] | undefined—
columnOrderKeysstring[] | undefined—
columnPinningRecord<string, "start" | "end"> | undefined—
columnVisibilityboolean | undefinedfalse
columnWidthsRecord<string, number> | undefined—
defaultCollapsedGroupKeysstring[] | undefined[]
defaultColumnOrderKeysstring[] | undefined—
defaultColumnWidthsRecord<string, number> | undefined{}
defaultSelectedKeysstring[] | undefined[]
defaultVisibleColumnKeysstring[] | undefined—
density"compact" | "comfortable" | undefined'comfortable'
emptyStateReactNode

Custom empty feedback for composed filter workflows.

—
errorstring | undefined—
filtersTableFilter<T>[] | undefined[]
groupingTableGrouping<T> | undefined

Client groups cover the filtered dataset; server groups describe only the supplied page.

—
loadingboolean | undefined—
multiSortboolean | undefined

Shift-select a column heading to add up to five ordered sort criteria.

false
onCollapsedGroupKeysChange((keys: string[]) => void) | undefined—
onColumnOrderKeysChange((keys: string[]) => void) | undefined—
onColumnWidthsChange((widths: Record<string, number>) => void) | undefined—
onRetry(() => void) | undefined—
onRowMove((move: TableRowMove) => void | Promise<void>) | undefined

Manual moves require an unfiltered, unsorted client table. The host saves and applies the order.

—
onSelectedKeysChange((keys: string[]) => void) | undefined—
onVisibleColumnKeysChange((keys: string[]) => void) | undefined—
pageSizenumber | undefined5
renderBulkActions((selectedRows: T[]) => ReactNode) | undefined—
renderSelectedActions((keys: string[]) => ReactNode) | undefined—
reorderableColumnsboolean | undefined

Reorder every column in the Columns menu, including hidden columns.

false
resizableColumnsboolean | undefinedfalse
rowLabel((row: T) => string) | undefinedrowKey
searchText((row: T) => string) | undefined—
selectableboolean | undefinedfalse
selectedKeysstring[] | undefined—
server{ query: TableQuery; onQueryChange: (query: TableQuery) => void; totalRows: number; } | undefined—
viewOptionsReactNode

Additional view controls inside the Columns popover.

—
visibleColumnKeysstring[] | undefined—

SortableDataTable

SortableDataTable public properties
PropTypeDefault
captionRequiredstring—
columnsRequiredColumn<T>[]—
rowKeyRequired(row: T) => string—
rowsRequiredT[]—
collapsedGroupKeysstring[] | undefined—
columnOrderKeysstring[] | undefined—
columnPinningRecord<string, "start" | "end"> | undefined—
columnVisibilityboolean | undefined—
columnWidthsRecord<string, number> | undefined—
defaultCollapsedGroupKeysstring[] | undefined—
defaultColumnOrderKeysstring[] | undefined—
defaultColumnWidthsRecord<string, number> | undefined—
defaultSelectedKeysstring[] | undefined—
defaultVisibleColumnKeysstring[] | undefined—
density"compact" | "comfortable" | undefined—
emptyStateReactNode

Custom empty feedback for composed filter workflows.

—
errorstring | undefined—
filtersTableFilter<T>[] | undefined—
groupingTableGrouping<T> | undefined

Client groups cover the filtered dataset; server groups describe only the supplied page.

—
loadingboolean | undefined—
multiSortboolean | undefined

Shift-select a column heading to add up to five ordered sort criteria.

—
onCollapsedGroupKeysChange((keys: string[]) => void) | undefined—
onColumnOrderKeysChange((keys: string[]) => void) | undefined—
onColumnWidthsChange((widths: Record<string, number>) => void) | undefined—
onRetry(() => void) | undefined—
onRowMove((move: TableRowMove) => void | Promise<void>) | undefined

Manual moves require an unfiltered, unsorted client table. The host saves and applies the order.

—
onSelectedKeysChange((keys: string[]) => void) | undefined—
onVisibleColumnKeysChange((keys: string[]) => void) | undefined—
pageSizenumber | undefined—
renderBulkActions((selectedRows: T[]) => ReactNode) | undefined—
renderSelectedActions((keys: string[]) => ReactNode) | undefined—
reorderableColumnsboolean | undefined

Reorder every column in the Columns menu, including hidden columns.

—
resizableColumnsboolean | undefined—
rowLabel((row: T) => string) | undefined—
searchText((row: T) => string) | undefined—
selectableboolean | undefined—
selectedKeysstring[] | undefined—
server{ query: TableQuery; onQueryChange: (query: TableQuery) => void; totalRows: number; } | undefined—
viewOptionsReactNode

Additional view controls inside the Columns popover.

—
visibleColumnKeysstring[] | undefined—

Column

Column public properties
PropTypeDefault
cellRequired(row: T) => ReactNode—
headerRequiredstring—
keyRequiredstring—
align"center" | "start" | "end" | undefined—
exportValue((row: T) => string | number) | undefined—
flexnumber | undefined

Extra available width is assigned to flexible columns.

—
hideableboolean | undefined—
minWidthnumber | undefined—
pinned"start" | "end" | undefined—
resizableboolean | undefined—
sortValue((row: T) => string | number) | undefined—
widthnumber | undefined—

TableQuery

TableQuery public properties
PropTypeDefault
filtersRequiredRecord<string, string>—
pageRequirednumber—
pageSizeRequirednumber—
searchRequiredstring—
sortRequiredTableSort | null—
sortsTableSort[] | undefined

Optional ordered multi-sort. When supplied, sort mirrors its first item.

—

TableFilter

TableFilter public properties
PropTypeDefault
keyRequiredstring—
labelRequiredstring—
optionsRequired{ value: string; label: string; }[]—
valueRequired(row: T) => string—

TableGrouping

TableGrouping public properties
PropTypeDefault
keyRequired(row: T) => string—
labelRequired(key: string) => string—

TableRowMove

TableRowMove public properties
PropTypeDefault
positionRequired"before" | "after"—
rowKeyRequiredstring—
targetKeyRequiredstring—

TableViewState

TableViewState public properties
PropTypeDefault
columnOrderKeysRequiredstring[]—
columnPinningRequiredRecord<string, "start" | "end">—
columnWidthsRequiredRecord<string, number>—
densityRequired"compact" | "comfortable"—
queryRequiredOmit<TableQuery, "page">—
versionRequired1—
visibleColumnKeysRequiredstring[]—

TableViewOptions

TableViewOptions public properties
PropTypeDefault
columnsRequiredreadonly TableViewColumn[]—
filterKeysreadonly string[] | undefined

Facet keys accepted by the host. Unknown facets are dropped on restoration.

—
pageSizesreadonly number[] | undefined

Defaults to 5, 10, 20, 50 and 100. The first value is the initial page size.

—

Tables come from the public TypeScript declarations. Related types and function parameters are shown alongside their component. A dash means no default is declared at the public function boundary.

Related controls

Notes to self

Test this component with real content, keyboard input and both themes. The example is a starting point; labels, error handling and behaviour still need to fit the application.