Usage
Hook that returns a TablePlugin which prepends a right-aligned, monospaced row-number column, starting at 1 by default. Without data, Table supplies row positions; with data, ordinary numbers follow that array. Windowed rows use the parent Table logical position directly; nondefault startFrom values use full rendering.
tsimport {useTableRowIndex} from '@astryxdesign/core/Table'
Parameters
| Param | Type | Description |
|---|---|---|
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.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.bashnpx shadcn@4.19.0 add https://astryx-ad4wwqfp4-fbopensource.vercel.app/shadcn/hooks/use-table-row-index.json