Table
Rows cascade in, a sortable header's arrow turns over on a spring and reports the sort to screen readers, and selected rows fade in. On a phone it scrolls sideways with a soft edge.
See it as an AI agent does.See this component the way an AI agent does.
Installation
npx shadcn@latest add @keyframery/tableThis adds components/keyframery/table.tsx and its primitive to your project, and installs UI SDK, along with agent-content, which it builds on. The motion tokens are added to your global CSS the first time you install a component.
Usage
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/keyframery/table"
export default function Usage() {
return (
<Table>
<TableHeader>
<TableRow>
<TableHead>Invoice</TableHead>
<TableHead>Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableCell>INV-001</TableCell>
<TableCell>€250.00</TableCell>
</TableRow>
</TableBody>
</Table>
)
}Anatomy
How the parts fit together:
Table
├── TableHeader
│ └── TableRow
│ └── TableHead
└── TableBody
└── TableRow
└── TableCellExamples
Basic
A header, a body, a footer for totals and a caption. Rows cascade in when the table first shows.
Sortable columns
Give a header sort and onSort and it becomes a button with an arrow that turns over on a spring. It sets aria-sort for screen readers.
Selecting rows
Put a Checkbox in the first column and pass selected to the row. The header's checkbox shows a dash when only some are ticked.
With pages
Give each row a stable key. When the page changes, the new rows cascade in; after a sort, rows that only moved stay still.
Wide tables on a phone
When the columns don't fit, the table scrolls sideways inside its container and the edge you can scroll toward fades. Narrow this window to see it.
Motion
| Move | What you see |
|---|---|
| Cascade | Rows arrive one after another, and new rows do the same when the page or filter changes. Rows that only move, like after a sort, stay put. |
| Spring | A sortable header's arrow turns over when the direction flips. |
| Fade | Hover and selected rows fade their colour in and out. |
| Direction | Too wide for the screen, it scrolls sideways and the edge you can scroll toward softens. |
Timing and springiness follow the motion style you set. To change how fast this table moves, pass speed:
<Table speed="fast">
…
</Table>"fast" is 0.6×, "slow" 1.4×, and a number sets the multiplier. With reduced motion turned on, nothing moves: changes happen at once or with a short fade.
Theming
Set these CSS variables on the component or a parent. Leave them unset to follow the light and dark theme. The open Customize panel below the preview lets you try these settings.
| Variable | What it changes | Default |
|---|---|---|
--table-ink | Table text | --foreground |
--table-muted | Headers and caption text | --muted-foreground |
--table-border | Row and footer rules | --border; 70% on rows |
--table-accent | Hover and selection tint | --foreground at 3% on hover and 6% when selected |
--table-footer | Footer fill | --muted at 40% |
--table-height | Body cell height | 2.75rem |
--table-padding | Cell horizontal padding | 0.75rem |
--table-radius | Sort button corners | 7px |
API reference
Every part takes className and children, along with the props of the element it renders. The parts are rendered by UI SDK, so they also take render, to draw your own element, and a function of their state for className and style.
Table
Renders a <table>, and takes its props too.
Prop
Type
TableRow
Renders a <tr>, and takes its props too.
Prop
Type
TableHead
Renders a <tableheadercell>, and takes its props too.
Prop
Type
Other parts
These take the props of the element they render, and nothing else:
TableHeader: a<tbody>TableBody: a<tbody>TableCell: a<tabledatacell>TableCaptionTableFooter: a<tbody>
Keyboard
| Key | What it does |
|---|---|
| Tab | Moves between the sort buttons, checkboxes and links in the table. |
| Enter | Sorts by the focused column, or turns its sort over. |
| Space | Sorts by the focused column, or ticks the focused row's checkbox. |
| Shift + scroll | Scrolls a wide table sideways. |
Accessibility
Roles, keyboard and focus are declared on the component's UI SDK primitive, and state is announced through the matching ARIA attributes. More in Accessibility.
Built on UI SDK's core
UI SDK doesn't ship a table, so this one is defined with its core: one definePrimitive in components/keyframery/core/table-core.ts, with no React in it. UI SDK's adapters can render that same definition in Vue, Svelte, Solid and web components. To keep your own styling and take only the motion, import from @/components/keyframery/primitives/table.
Questions
How does the animated Table for UI SDK move?
Cascade: Rows arrive one after another, and new rows do the same when the page or filter changes. Rows that only move, like after a sort, stay put. Spring: A sortable header's arrow turns over when the direction flips. Fade: Hover and selected rows fade their colour in and out. Direction: Too wide for the screen, it scrolls sideways and the edge you can scroll toward softens.
Do I need Motion or Framer Motion for the animated Table?
No. Every move is plain CSS, so there is nothing to install besides the component and UI SDK.
UI SDK has no table. How is this one built on UI SDK?
Its behaviour is one definition written with UI SDK's core (definePrimitive), in components/keyframery/core/table-core.ts. Its parts are rendered by UI SDK's adapter, so they take render, state-based class names and data-slot, like every UI SDK component.
What happens to the Table when someone turns on reduced motion?
Nothing moves. State changes happen at once, or with a short fade.
More in Data
All componentsStat
The KPI card of an admin dashboard: a label, one big number, the change as a coloured pill with an arrow, a comparison line, an optional icon and room for a sparkline, with a loading state at the parts' own size. When the numbers change the value rolls digit by digit, the delta's arrow turns to its new direction and the sparkline tweens. StatGroup sets several on one surface with hairlines between them, four across, then two, then one, by container queries.
Waterfall
Request bars grow from their start time one row after another, and nested spans cascade in.