useTableRowIndex@astryxdesign/core v0.5.2 · useTableRowIndex

Usage

Hook that returns a TablePlugin which prepends a right-aligned, monospaced row-number column. Numbering follows the rendered data order (reflecting the current sort / filter / pagination view) and starts at 1 by default. Astryx renderCell receives only the row item, so the plugin takes the rendered data array to derive each ordinal.

ts
import {useTableRowIndex} from '@astryxdesign/core/Table'

Parameters

ParamTypeDescription
datarequired
T[]

The data array currently rendered by the table (post sort/filter/page). Numbering follows this order.

getRowKey
(item: T) => string

Optional key extractor returning a unique string per row. When provided, index lookup is keyed by the returned string; otherwise items are matched by reference identity. Memoize with useCallback for a stable plugin identity.

label
ReactNode (default: '#')

Header label for the index column.

startFrom
number (default: 1)

First index value.

Examples

Common configurations, variations, and states.
useTableRowIndex — Numbered Rows
Open in Playground

A table with a prepended row-number column via useTableRowIndex. Numbering is monospaced, right-aligned, and follows the rendered data order.