useTableRowIndex@astryxdesign/core v0.7.11 · useTableRowIndex

Usage

Hook that returns a TablePlugin which prepends a right-aligned, monospaced row-number column. Numbering follows the rows the table renders (reflecting the current sort / filter / pagination view) and starts at 1 by default. Without data, Table gives each row its position; with data, numbers follow that array.

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

Parameters

ParamTypeDescription
data
T[]

Optional: the array whose order the numbers follow. Omit it to number rows from the positions Table gives them.

getRowKey
(item: T) => string

Optional key extractor used with data, returning a unique string per row. When provided, rows match data by the returned string; otherwise 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 rows the table renders.

Use with shadcn

Already using the shadcn registry workflow? Install the real Astryx package and a local public re-export. Component implementation source stays in Astryx.

This install URL expires with the draft preview.
bash
npx shadcn@4.19.0 add https://astryx-a8z75h0ae-fbopensource.vercel.app/shadcn/hooks/use-table-row-index.json