Component-Specific

useDataTable

Comprehensive data table state management with sorting, filtering, and pagination.

import { useDataTable } from "saha-ui"

Uses

Comprehensive table state management: sorting, filtering, column visibility, row selection and pagination. Designed to power a `DataTable` component instance.

Props

NameTypeDescriptionDefault
dataarrayRow data.-
columnsColumnDef[]Column definitions including accessor and optional filter/sort functions.-
enableSortingbooleanEnable sorting.true
enableFilteringbooleanEnable filtering.true
enablePaginationbooleanEnable pagination.true
pageSizenumberInitial items per page.10

Returns

NameDescription
APIAPI resembling a table instance: getRowModel, getHeaderGroups, getState.
ControlssetPageIndex, nextPage, setSorting, setColumnFilters, setColumnVisibility, setRowSelection, setGlobalFilter, etc.
Computedrows, paginatedRows, page count, visibility and sorting helpers.

Example

const table = useDataTable({ data, columns, pageSize: 20 }); const { getRowModel, nextPage } = table;

Notes

Supports mixed controlled/uncontrolled patterns: provide controlled props to override internal state and use change callbacks to sync.
Saha UI - The Modern React Component Library