Table

A responsive table component with support for variants, alignment, and a useTable hook for declarative column configuration.

View Markdown

Basic

A list of your recent invoices.
InvoiceStatusMethodAmount
INV001PaidCredit Card$250.00
INV002PendingPayPal$150.00
INV003UnpaidBank Transfer$350.00
INV004PaidCredit Card$450.00
INV005PaidPayPal$550.00

Variants

Default

NameEmailRoleDepartment
Alice Johnsonalice@example.comAdminEngineering
Bob Smithbob@example.comUserMarketing
Charlie Browncharlie@example.comUserSales
Diana Princediana@example.comEditorDesign

Striped

NameEmailRoleDepartment
Alice Johnsonalice@example.comAdminEngineering
Bob Smithbob@example.comUserMarketing
Charlie Browncharlie@example.comUserSales
Diana Princediana@example.comEditorDesign

Bordered

NameEmailRoleDepartment
Alice Johnsonalice@example.comAdminEngineering
Bob Smithbob@example.comUserMarketing
Charlie Browncharlie@example.comUserSales
Diana Princediana@example.comEditorDesign

Compact

NameEmailRoleDepartment
Alice Johnsonalice@example.comAdminEngineering
Bob Smithbob@example.comUserMarketing
Charlie Browncharlie@example.comUserSales
Diana Princediana@example.comEditorDesign

Pagination

IDProduct NamePriceCategory
1Product 1$167.03Electronics
2Product 2$39.16Clothing
3Product 3$177.75Books
4Product 4$119.01Home
5Product 5$154.48Electronics
6Product 6$206.61Clothing
7Product 7$184.67Books
8Product 8$61.79Home
9Product 9$183.65Electronics
10Product 10$181.14Clothing
Showing 1-10 of 47 items

Sorting

IDProduct NamePriceIn StockCreated
5Headphones$149.99No2/28/2024
3Keyboard$79.99No1/10/2024
1Laptop$999.99Yes1/15/2024
4Monitor$349.99Yes3/5/2024
2Mouse$29.99Yes2/20/2024
6Webcam$89.99Yes1/22/2024
IDNameEmailRole
1Alice Johnsonalice@example.comAdmin
2Bob Smithbob@example.comUser
3Charlie Browncharlie@example.comUser
4Diana Rossdiana@example.comModerator
5Edward Nortonedward@example.comUser
6Fiona Applefiona@example.comAdmin
6 results

Filters

InvoiceCustomerEmailAmountStatus
INV-001Acme Corpbilling@acme.com$1,250paid
INV-002Globex Incap@globex.com$430pending
INV-003Stark Industriestony@stark.com$890overdue
INV-004Wayne Enterprisesbruce@wayne.com$2,100paid
INV-005Umbrella Corpfinance@umbrella.com$560pending
INV-006Cyberdyne Systemsaccounts@cyberdyne.com$1,800paid
INV-007Oscorpnorman@oscorp.com$340overdue
INV-008LexCorplex@lexcorp.com$1,500pending
8 results

Row Selection

0 rows selected
IDNameEmailRole
1Alice Johnsonalice@example.comAdmin
2Bob Smithbob@example.comEditor
3Carol Williamscarol@example.comViewer
4David Browndavid@example.comEditor
5Eva Martinezeva@example.comAdmin
Showing 1-5 of 12 users

Row Expansion

IDNameEmailRole
1Alice Johnsonalice@example.comAdmin
2Bob Smithbob@example.comEditor
3Carol Williamscarol@example.comViewer
4David Browndavid@example.comEditor
5Eva Martinezeva@example.comAdmin

Empty State

InvoiceStatusMethodAmount

No invoices found

There are no invoices to display. Create your first invoice to get started.

Loading State

InvoiceStatusMethodAmount

API Reference

useTable Options

Options passed to the useTable hook.

PropTypeDefaultDescription
data*T[]-Array of data items to display in the table
columns*ColumnDef<T>[]-Column definitions for the table
paginationPaginationConfig-Enable pagination with page size options
sort{ key: keyof T; direction: SortDirection }-Initial sort configuration
searchSearchConfig<T>-Enable search functionality
filtersFiltersConfig<T>-Filter definitions for the table
selectionSelectionConfig<T>-Enable row selection functionality
expansionExpansionConfig<T>-Enable row expansion functionality

useTable Return

Values and functions returned by the useTable hook.

PropTypeDescription
columnsProcessedColumn<T>[]Processed columns with head/cell props and renderCell function
rowsT[]Current page of filtered, sorted data
totalItemsnumberTotal number of items after filtering
currentPagenumberCurrent page number (1-indexed)
totalPagesnumberTotal number of pages
pageSizenumberCurrent page size
pageSizeOptionsnumber[]Available page size options
onPageChange(page: number) => voidCallback to change current page
onPageSizeChange(size: number) => voidCallback to change page size
sortKeykeyof T | nullCurrently sorted column key
sortDirectionSortDirectionCurrent sort direction
onSort(key: keyof T) => voidCallback to toggle sort on a column
searchTermstringCurrent search term
onSearchChange(term: string) => voidCallback to update search term
filterValuesFilterValuesCurrent filter values by filter ID
setFilterValue(filterId: string, value: unknown) => voidSet a filter value
clearFilters() => voidClear all filter values
activeFilterCountnumberNumber of active filters
selectionSelectionStateSelection state and handlers (only present when selection config provided)
expansionExpansionStateExpansion state and handlers (only present when expansion config provided)

ColumnDef

Column definition for the table.

PropTypeDefaultDescription
key*keyof T-Property key to access row data
header*ReactNode-Content to display in column header
cell(value: T[K], row: T) => ReactNode-Custom cell renderer
format(value: T[K], row: T) => string-Format value as string (used if cell not provided)
sortablebooleanfalseEnable sorting for this column
widthstring | number-Column width (CSS value)
classNamestring-Class applied to both header and cells
headerClassNamestring-Class applied to header only
cellClassNamestring-Class applied to cells only

PaginationConfig

Configuration for table pagination.

PropTypeDefaultDescription
pageSize*number-Initial number of rows per page
pageSizeOptionsnumber[][10, 25, 50, 100]Available page size options

SearchConfig

Configuration for table search.

PropTypeDefaultDescription
keys*(keyof T)[]-Row properties to search in

FiltersConfig

Map of filter ID to FilterDef. Each filter can have a different value type.

PropTypeDefaultDescription
predicate*(row: T, value: V) => boolean-Returns true if row passes the filter
defaultValueV-Initial filter value

SelectionConfig

Configuration for row selection. Supports both controlled and uncontrolled modes.

PropTypeDefaultDescription
rowKey*(row: T) => string | number-Function to extract unique key from each row
defaultSelectedKeys(string | number)[]-Initial selected keys (uncontrolled mode)
selectedKeys(string | number)[]-Controlled selected keys
onSelectionChange(keys: (string | number)[]) => void-Callback when selection changes

SelectionState

Selection state returned by useTable when selection is enabled.

PropTypeDescription
selectedKeys(string | number)[]Array of currently selected row keys
selectedCountnumberNumber of selected rows
isSelected(key: string | number) => booleanCheck if a row key is selected
toggleRow(key: string | number) => voidToggle selection state by row key
isRowSelected(row: T) => booleanCheck if a row is selected (uses rowKey internally)
toggleRowSelection(row: T) => voidToggle selection state of a row (uses rowKey internally)
toggleAllOnPage() => voidToggle selection of all rows on current page
clearSelection() => voidClear all selections
pageSelectionState'all' | 'some' | 'none'Selection state for current page rows
isIndeterminatebooleanTrue when some (but not all) page rows are selected
isAllOnPageSelectedbooleanTrue when all page rows are selected

ExpansionConfig

Configuration for row expansion.

PropTypeDefaultDescription
rowKey*(row: T) => string | number-Function to extract unique key from each row

ExpansionState

Expansion state returned by useTable when expansion is enabled. Expanded rows auto-collapse when page, sort, or filters change.

PropTypeDescription
expandedKeys(string | number)[]Array of currently expanded row keys
expandedCountnumberNumber of expanded rows
isExpanded(key: string | number) => booleanCheck if a row key is expanded
toggleExpansion(key: string | number) => voidToggle expansion state by row key
isRowExpanded(row: T) => booleanCheck if a row is expanded (uses rowKey internally)
toggleRowExpansion(row: T) => voidToggle expansion state of a row (uses rowKey internally)
collapseAll() => voidCollapse all expanded rows

TableRoot

The root table element with variant and size support.

PropTypeDefaultDescription
variant'default' | 'striped' | 'bordered''default'Visual style variant
size'default' | 'compact''default'Table density size
stickyHeaderbooleanfalseSkips the overflow wrapper and makes thead sticky. Use inside a scroll container for fixed-height scrollable tables.
...propsReact.ComponentProps<"table">-Standard table element props

TableHead

Table header cell with optional sorting support.

PropTypeDefaultDescription
sortableboolean-Show sort indicator
sortDirectionSortDirection-Current sort direction ('asc' | 'desc')
onSort() => void-Callback when header is clicked
...propsReact.ComponentProps<"th">-Standard th element props

TableCaption

Table caption element with positioning.

PropTypeDefaultDescription
position'top' | 'bottom''bottom'Caption position relative to table
...propsReact.ComponentProps<"caption">-Standard caption element props

Other Primitives

Standard table primitives with styling.

PropTypeDescription
TableHeaderReact.ComponentProps<"thead">Table header group (thead)
TableBodyReact.ComponentProps<"tbody">Table body group (tbody)
TableFooterReact.ComponentProps<"tfoot">Table footer group (tfoot)
TableRowReact.ComponentProps<"tr">Table row (tr)
TableCellReact.ComponentProps<"td">Table cell (td)

Filter Helpers

Utility functions for creating common filter predicates.

PropTypeDescription
includesFilter(key)FilterPredicate<T, T[K][]>Multi-select: row value is in selected array
rangeFilter(key)FilterPredicate<T, [number, number]>Range: numeric value is within [min, max]
containsFilter(key)FilterPredicate<T, string>Contains: string value includes search term (case-insensitive)
equalsFilter(key)FilterPredicate<T, T[K]>Equals: row value strictly equals filter value

Types

Type definitions exported from the table package.

PropTypeDescription
SortDirection'asc' | 'desc'Sort direction type
TableVariant'default' | 'striped' | 'bordered'Table variant type
TableSize'default' | 'compact'Table size type
ColumnDef<T>interfaceColumn definition interface
ProcessedColumn<T>interfaceProcessed column returned by useTable
PaginationConfiginterfacePagination configuration interface
SearchConfig<T>interfaceSearch configuration interface
FilterDef<T, V>interfaceFilter definition interface
FiltersConfig<T>typeMap of filter IDs to FilterDef
FilterValuestypeMap of filter IDs to current values
FilterPredicate<T, V>typeFilter predicate function type
UseTableOptions<T>interfaceuseTable hook options
UseTableReturn<T>interfaceuseTable hook return type
SelectionConfig<T>interfaceSelection configuration interface
SelectionState<T>interfaceSelection state interface
ExpansionConfig<T>interfaceExpansion configuration interface
ExpansionState<T>interfaceExpansion state interface
RowKeyGetter<T>typeFunction type to extract row key