Table
A sortable data table with FLIP row transitions, spring sort chevrons, sliding hover highlight, spring row add/remove collapse, directional paging, and optional stagger-table and expand-row effects.
Sorted by Duration ascending
| Spring | Action | ||
|---|---|---|---|
ElasticSlider | press | 150ms | |
KineticToast | snappy | 165ms | |
BlurSelect | pop | 180ms | |
SpringTabs | selection | 210ms |
Customize
Installation
Add the base component with the registry command:
npx shadcn@latest add @kinetic/tableInstall optional table effects separately when you need them:
npx shadcn@latest add @kinetic/stagger-table
npx shadcn@latest add @kinetic/expand-rowUsage
Give each TableRow a stable rowKey and pass sortDirection and onSort to sortable TableHead cells. Rows slide into their new positions via FLIP when sorted, and aria-sort stays on the <th>.
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
type TableSortDirection,
} from "@/components/kinetic/ui/table";
interface TableRowItem {
readonly id: string;
readonly name: string;
readonly durationMs: number;
}
interface SortableTableProps {
readonly rows: readonly TableRowItem[];
readonly sortDir: TableSortDirection;
readonly onToggleSort: () => void;
}
export function SortableTable({ rows, sortDir, onToggleSort }: SortableTableProps) {
return (
<Table>
<TableHeader>
<TableRow>
<TableHead>Name</TableHead>
<TableHead sortDirection={sortDir} onSort={onToggleSort}>
Duration
</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{rows.map((row) => (
<TableRow key={row.id} rowKey={row.id}>
<TableCell>{row.name}</TableCell>
<TableCell>{row.durationMs}ms</TableCell>
</TableRow>
))}
</TableBody>
</Table>
);
}Add, remove, and paging
Set open={false} with onExitComplete on TableRow to collapse height and fade out before unmounting, or animateMount to reveal newly inserted rows. Pass page and pageDirection on TableBody to slide content left or right between pages.
<TableBody page={page} pageDirection={pageDirection}>
{rows.map((row) => (
<TableRow
key={row.id}
rowKey={row.id}
open={row.open}
animateMount
onExitComplete={() => removeRow(row.id)}
>
<TableCell>{row.name}</TableCell>
</TableRow>
))}
</TableBody>Stagger
Use StaggerTable and StaggerTableBody from @kinetic/stagger-table to reveal rows sequentially once loading changes from true to false.
import { StaggerTable, StaggerTableBody } from "@/components/kinetic/ui/stagger-table";
import { TableCell, TableHead, TableHeader, TableRow } from "@/components/kinetic/ui/table";
interface StaggerExampleProps {
readonly loading: boolean;
readonly rows: readonly { readonly id: string; readonly label: string }[];
}
export function StaggerExample({ loading, rows }: StaggerExampleProps) {
return (
<StaggerTable>
<TableHeader>
<TableRow>
<TableHead>Item</TableHead>
</TableRow>
</TableHeader>
<StaggerTableBody loading={loading}>
{rows.map((row) => (
<TableRow key={row.id} rowKey={row.id}>
<TableCell>{row.label}</TableCell>
</TableRow>
))}
</StaggerTableBody>
</StaggerTable>
);
}Expand row
Use ExpandableRow, ExpandRowTrigger, and ExpandRowContent from @kinetic/expand-row to expand a colSpan detail row smoothly with spring height physics and synced aria-expanded / aria-controls attributes.
import {
ExpandableRow,
ExpandRowContent,
ExpandRowTrigger,
} from "@/components/kinetic/ui/expand-row";
import { TableCell } from "@/components/kinetic/ui/table";
interface DetailRowProps {
readonly title: string;
readonly summary: string;
}
export function DetailRow({ title, summary }: DetailRowProps) {
return (
<ExpandableRow
colSpan={2}
detail={<ExpandRowContent>{summary}</ExpandRowContent>}
>
<TableCell>
<ExpandRowTrigger aria-label={`Toggle ${title}`} />
</TableCell>
<TableCell>{title}</TableCell>
</ExpandableRow>
);
}Performance
Animations run only when the visible body row count is at or below animateRowLimit (default 50) and reduced motion is off. Larger visible tables automatically switch to static rendering and CSS row hover so scrolling and sorting stay responsive.
API Reference
Table
Root table container coordinating sliding hover highlight, speed, and row animation threshold.
| Prop | Type | Default | Description |
|---|---|---|---|
animateRowLimit | number | 50 | Disables FLIP, stagger, size collapse, and sliding hover highlight when visible rows exceed this limit. |
showHoverHighlight | boolean | true | Enables the vertical sliding hover indicator behind body rows on fine pointers. |
sortAnnouncement | string | - | Text rendered in a visually hidden status region for screen readers after sorting. |
speed | number | 1 | Speed multiplier across table FLIP, spring arrows, row collapse, and paging (0.25-4). |
TableHead / TableSortButton
Header cell supporting accessible aria-sort and a snappy-spring rotating sort chevron.
| Prop | Type | Default | Description |
|---|---|---|---|
sortDirection | "asc" | "desc" | null | null | Sets aria-sort on the th element and rotates the sort chevron smoothly. |
onSort | () => void | - | Renders an accessible sort button inside the th cell and invokes callback on click. |
TableBody / TableRow
FLIP row reorder body with directional paging, plus row add/remove height and fade transitions.
| Prop | Type | Default | Description |
|---|---|---|---|
page / pageDirection (TableBody) | number | string / 1 | -1 | - | Slides the body left or right horizontally when the current page changes. |
rowKey / open / animateMount / onExitComplete (TableRow) | string | number / boolean / boolean / () => void | open=true / animateMount=false | Identifies rows for FLIP tracking and animates row height and opacity via useAnimatedSize. |
StaggerTable / StaggerTableBody
Optional stagger-table effect revealing rows sequentially when loading transitions to false.
| Prop | Type | Default | Description |
|---|---|---|---|
loading / staggerMs / maxStaggerMs | boolean / number / number | false / 35 / 220 | Triggers capped row stagger reveal once data loading completes under the row limit. |
ExpandableRow / ExpandRowTrigger / ExpandRowContent
Optional expand-row effect opening a colSpan detail row smoothly with spring height.
| Prop | Type | Default | Description |
|---|---|---|---|
expanded / defaultExpanded / onExpandedChange / colSpan / detail | boolean / boolean / (open: boolean) => void / number / ReactNode | - | Controls detail row expansion state, table column span, and collapsible detail content. |