Table
Sortable Table
A glass data table whose rows glide to their new places when you sort a column.
Built from Pulse Badge — installed with it.
npx motionsnack add sortable-tableCustomize
<SortableTable />Props
29 properties
| Property | Type | Default | Description |
|---|---|---|---|
| columns | { key: string; label: string; align?: 'start' | 'center' | 'end'; sortable?: boolean; width?: number | string }[] | 4 demo columns | Columns, start to end. Numbers, money and dates align end. |
| rows | Record<string, string | number>[] | 6 demo rows | Rows as plain objects keyed by the column keys, each with a unique rowKey field. Values like '$12,400' sort as numbers. |
| statusTones | Record<string, 'success' | 'warning' | 'error' | 'neutral'> | { Active, Paused, Draft } | Status of a badge by its value. |
| sort | { key: string; direction: 'ascending' | 'descending' } | null | - | Sort. With a value (or null) the component is controlled. |
| defaultSort | { key: string; direction: 'ascending' | 'descending' } | null | null | Sort at the start when uncontrolled. |
| onSortChange | (sort | null) => void | - | Called after a header click. |
| selection | string[] | - | Selected row keys. With a value the selection is controlled. |
| defaultSelection | string[] | [] | Selected row keys at the start when uncontrolled. |
| onSelectionChange | (keys: string[]) => void | - | Called with the selected row keys after a user change. |
| onRetry | () => void | - | Called by the Retry button of the error row. |
| labels | SortableTableLabels | English | Count, caption note, announcements, checkbox names, empty-cell text. |
| locale | string | 'en-US' | BCP 47 locale of sorting and counts. |
| accent | string | - | Deprecated, ignored: the sort arrow is monochrome. |
| radius | number | - | Deprecated, ignored: the frame is radius 16. |
| rowHeight | number | - | Deprecated: use height. |
| minWidth | number | - | Deprecated, ignored: columns are at least 80 wide. |
| hoverHighlight | boolean | - | Deprecated, ignored. |
| duration | number | - | Deprecated, ignored. |
| bounce | number | - | Deprecated, ignored. |
| className | string | '' | Extra classes on the frame. |
| caption | string | 'Projects' | Title above the table, also the table caption. Empty hides the title bar. |
| rowKey | string | 'id' | Field that identifies a row. |
| statusKey | string | 'status' | Column key whose values are drawn as status badges. Empty turns them off. |
| height | '40' | '48' | '40' | Row height; the header matches. |
| selectable | boolean | false | Checkbox column for row selection. |
| stickyHeader | boolean | false | Header sticks to the top of the scroll container. |
| loading | boolean | false | Skeleton without rows, dimmed rows otherwise. |
| error | string | '' | Error message: replaces the body with one row. |
| emptyText | string | 'No results' | Text of the empty body. |
About Sortable Table
Sortable Table takes plain column definitions and an array of row objects and renders them in a glass card. Clicking a header sorts by that column: the first click ascending, the second descending, the third back to the original order. Instead of snapping, every row travels to its new position on a spring while the sort arrow rotates and takes the accent colour. A soft highlight follows the pointer from row to row, and one column can be drawn as status pills with coloured dots. Values such as prices and percentages sort as numbers, and the table scrolls sideways when the space gets too narrow.
What's included
- Rows glide to their new order with a spring layout animation
- Three-step sort per column: ascending, descending, original
- Rotating sort arrow in the accent colour
- Hover highlight that follows the pointer between rows
- Optional status pill column with tone colours
- Controlled or uncontrolled sort with onSortChange
- Horizontal scroll on narrow widths, light and dark looks
- Type
- Animated React table component
- Library
- Components · Table
- Stack
- Next.js, React, Tailwind CSS
- Added
- 2026-09-20