Install with shadcn
Experimental compatibility. This installs the real Astryx package and creates a local public re-export; it does not copy component implementation source. How compatibility works.
This install URL expires with the draft preview.bashnpx shadcn@latest add https://astryx-2z5i6c2u1-fbopensource.vercel.app/r/astryx-component-use-table-row-index.json
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.
tsimport {useTableRowIndex} from '@astryxdesign/core/Table'
Parameters
| Param | Type | Description |
|---|---|---|
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.A table with a prepended row-number column via useTableRowIndex. Numbering is monospaced, right-aligned, and follows the rendered data order.