Table Features

Built-in table mechanics including sorting, pinning, resizing, pagination, and controlled state.

Overview

DataTable directly owns sorting, column pinning, column resizing, pagination and controlled/uncontrolled table state.

Search, filtering, column visibility, and bulk-action UI are covered on their own pages because they are composed around the table rather than folded into the DataTable API surface.

Sorting

Turn on sorting with enableSorting. By default the table manages its own sorting state. Switch to controlled mode only when that state needs to live somewhere else.

Column Pinning

Turn on pinning with enableColumnPinning to let users stick important columns to the left or right edge of the table.

Column Resizing

Turn on resizing with enableColumnResizing to let users adjust column widths with drag handles.

Pagination

Turn on pagination with enablePagination. The default uncontrolled state starts at page 0 with a page size of 10.

Controlled vs Uncontrolled

Every built-in table feature follows the same pattern:

  • pass initial* props for uncontrolled setup
  • pass both value and onChange props for controlled state
  • keep state outside the table only when another part of your UI needs it
<DataTable
  data={data}
  columns={columns}
  enableSorting
  enableColumnPinning
  sorting={sorting}
  onSortingChange={setSorting}
  columnPinning={columnPinning}
  onColumnPinningChange={setColumnPinning}
/>

Row Interaction and Escape Hatches

Use onRowClick when rows should trigger navigation or open another surface. Use tableOptions only when you need a lower-level TanStack option that Cubitt does not expose directly.

API Reference

Feature Flags

PropTypeDefaultDescription
enableSortingbooleanfalseEnable sortable column headers
enableColumnPinningbooleanfalseEnable sticky left and right pinned columns
enableColumnResizingbooleanfalseEnable drag handles for column sizing
enablePaginationbooleanfalseEnable TanStack pagination row model

Sorting

PropTypeDefaultDescription
initialSortingSortingState[]Initial uncontrolled sorting
sortingSortingState-Controlled sorting state
onSortingChangeOnChangeFn<SortingState>-Sorting change handler

Column Pinning

PropTypeDefaultDescription
initialColumnPinningColumnPinningState{}Initial uncontrolled pinning
columnPinningColumnPinningState-Controlled pinning state
onColumnPinningChangeOnChangeFn<ColumnPinningState>-Pinning change handler
onColumnPin(columnId, position) => void-Called when a column is pinned or unpinned

Pagination

PropTypeDefaultDescription
initialPaginationPaginationState{ pageIndex: 0, pageSize: 10 }Initial uncontrolled pagination
paginationPaginationState-Controlled pagination state
onPaginationChangeOnChangeFn<PaginationState>-Pagination change handler

Resizing

PropTypeDescription
onColumnResize(columnId: string, size: number) => voidCalled after a column is resized

Other Core Props

PropTypeDescription
onRowClick(row: Row<TData>) => voidRow click handler
tableOptionsPartial<TableOptions<TData>>Additional TanStack Table options

On this page