useTableRowIndex@astryxdesign/core v0.7.9 · 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. Table gives each row its position, so the plugin needs no data.

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

Parameters

ParamTypeDescription
data
T[]

Optional fallback: the data array the table renders (post sort/filter/page). Only an index cell rendered outside the table body rows uses it.

getRowKey
(item: T) => string

Optional key extractor for the data fallback, returning a unique string per row. When provided, the fallback matches rows 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 rendered data order.

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-din9ozdag-fbopensource.vercel.app/shadcn/hooks/use-table-row-index.json