Keyframery

Data table

The full list screen on top of Table, with no table library: give it data and columns and it owns the search, faceted filters with live counts, the sort, hidden columns, row selection, the page and the page size, each one controlled or not so a page can keep it in the URL. Rows cascade in after a sort or a page turn, a hidden column folds away while the others close the gap, Reset slides in while anything is filtered, and a bulk bar rises from the bottom centre while rows are selected.

See it as an AI agent does.

Resize preview. Focus the handle and use the left or right arrow keys. Hold Shift for larger steps.— px
Customize1 controls
Animation speed1×

Installation

npx shadcn@latest add @keyframery/data-table

This adds components/keyframery/data-table.tsx and its primitive to your project, and installs UI SDK, along with badge, button, checkbox, empty, filter, input-group, menu, pagination, select, skeleton, table, toolbar, which it builds on. The motion tokens are added to your global CSS the first time you install a component.

Usage

import { DataTable, type DataTableColumnDef } from "@/components/keyframery/data-table"

type Order = { id: string; customer: string; status: string; total: number }

const orders: Order[] = [
  { id: "1042", customer: "Maya Chen", status: "Paid", total: 184 },
  { id: "1041", customer: "Tom Okafor", status: "Pending", total: 62.5 },
]

const columns: DataTableColumnDef<Order>[] = [
  { id: "id", header: "Order", searchable: true },
  { id: "customer", header: "Customer", searchable: true },
  { id: "status", header: "Status", filter: { options: [{ value: "Paid" }, { value: "Pending" }] } },
  { id: "total", header: "Total", align: "end" },
]

export default function Usage() {
  return <DataTable label="Orders" data={orders} columns={columns} />
}

Examples

A list screen

Search, filters with counts, sortable headers, selection, a row menu and a bulk bar, all from data and columns.

State in your hands

Every piece of state is controlled or not: here the search, the filters, the sort and the page live in the page's own state, the way you would keep them in the URL.

Loading

loading keeps the toolbar and headers and draws skeleton rows at the table's own geometry, one per row of the page.

Motion

MoveWhat you see
CascadeAfter a sort or a page turn the page's rows arrive one after another, rising from below for Next and dropping from above for Previous. After a search or a filter only the rows new to the page arrive; selecting replays nothing.
CollapseA hidden column folds to nothing, its text blurring out, while the other columns close the gap; a column shown again opens out of nothing.
RiseThe bulk bar rises from the bottom centre on a spring, from a smaller, blurred start, and sinks away when the selection is cleared.
RollThe selected count, the row count and the page number roll to each new number.
SlideReset slides in beside the filters while the search or a filter is on, and folds away when they clear.
DrawRow checks and the select-all dash draw themselves (from Checkbox).
GlideThe current page key glides along the pagination, and the highlight glides through every menu and the bulk bar.

Timing and springiness follow the motion style you set. To change how fast this data table moves, pass speed:

<DataTable speed="fast">
  …
</DataTable>

"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.

VariableWhat it changesDefault
--data-table-surfaceThe table's card and its sticky cells--card
--data-table-borderThe card's hairlineblack 7%; white 8% in dark
--data-table-accentThe hover and selected row tint--foreground
--data-table-radiusThe card's corners14px
--data-table-row-heightEach row's height2.75rem
--data-table-barThe bulk bar's surface--popover

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.

DataTable

Renders a <div>, and takes its props too.

Prop

Type

DataTableBulkAction

Renders a <button>, and takes its props too.

Prop

Type

DataTableColumnHeader

Renders a <div>, and takes its props too.

Prop

Type

DataTableContent

Prop

Type

DataTableEmpty

Renders a <div>, and takes its props too.

Prop

Type

DataTableToolbar

Prop

Type

DataTableRoot

Renders a <div>, and takes its props too.

Prop

Type

Other parts

These take the props of the element they render, and nothing else:

  • DataTableBulkBar
  • DataTableFilters
  • DataTableFooter: a <div>
  • DataTableReset
  • DataTableSearch: a <div>
  • DataTableView: a <div>
  • DataTableHead: a <tableheadercell>
  • DataTableRow: a <tr>

Hooks

useColumnPresence

Call it inside the component to read and change its state.

Prop

Type

useDataTable

Call it inside the component to read and change its state.

Prop

Type

Keyboard

KeyWhat it does
TabMoves through the search field, the filter chips, Reset, View, the select-all, each sortable header, then each row's checkbox and menu, the bulk bar and the footer.
EnterOn a header, opens its menu: Asc, Desc and Hide. On a filter chip or View, opens it.
ArrowDownMoves through the open menu's items; in the bulk bar, ArrowRight and ArrowLeft move between its buttons.
SpaceChecks or unchecks the focused row's checkbox or the select-all for the page; toggles a column in View.
EscapeCloses an open menu; with nothing open, clears the selection while focus is in the table.

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 data table, so this one is defined with its core: one definePrimitive in components/keyframery/core/data-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/data-table.

Questions

How does the animated Data table for UI SDK move?

Cascade: After a sort or a page turn the page's rows arrive one after another, rising from below for Next and dropping from above for Previous. After a search or a filter only the rows new to the page arrive; selecting replays nothing. Collapse: A hidden column folds to nothing, its text blurring out, while the other columns close the gap; a column shown again opens out of nothing. Rise: The bulk bar rises from the bottom centre on a spring, from a smaller, blurred start, and sinks away when the selection is cleared. Roll: The selected count, the row count and the page number roll to each new number. Slide: Reset slides in beside the filters while the search or a filter is on, and folds away when they clear. Draw: Row checks and the select-all dash draw themselves (from Checkbox). Glide: The current page key glides along the pagination, and the highlight glides through every menu and the bulk bar.

Do I need Motion or Framer Motion for the animated Data table?

No. Every move is plain CSS, so there is nothing to install besides the component and UI SDK.

UI SDK has no data 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/data-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 Data table when someone turns on reduced motion?

Nothing moves. State changes happen at once, or with a short fade.

All components

On this page