Components

Table

The shadcn/ui Table with row hover polish, a lit selected state and tabular numbers — plus two animated React table blocks built with Motion: a self-contained data table with sorting, filtering, row selection and pagination whose rows glide when they reorder, and a table with expandable detail rows.

  • Drop-in shadcn API
  • Server Component friendly
  • No table library
  • aria-sort
  • prefers-reduced-motion
Recent payments
Ruby Silvaruby@harbor.dev
succeeded$1,290.00
Noah Kimnoah@orbit.app
failed$874.00
Mia Rossimia@lumen.so
succeeded$837.00
Zoe Martinzoe@pixel.co
succeeded$721.00
Nora Jensennora@fjord.co
succeeded$512.00

1 of 12 row(s) selected.

Page 1 of 3

Installation

$ npx shadcn@latest add https://duskui.com/r/table.json

Adds components/ui/table.tsx with the same parts as shadcn plus containerClassName for the scrolling wrapper. CSS only — no "use client" needed.

Usage

invoices.tsx
import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from "@/components/ui/table"

export function Invoices() {
  return (
    <Table>
      <TableHeader>
        <TableRow>
          <TableHead scope="col">Invoice</TableHead>
          <TableHead scope="col" className="text-right">Amount</TableHead>
        </TableRow>
      </TableHeader>
      <TableBody>
        <TableRow>
          <TableCell>INV-1042</TableCell>
          <TableCell className="text-right">$250.00</TableCell>
        </TableRow>
      </TableBody>
    </Table>
  )
}

Examples

Default

Hover a row: its background lightens slightly. Header and footer rows stay still.

A list of your recent invoices.
InvoiceStatusMethodAmount
INV-1042PaidCredit card$250.00
INV-1043PendingPayPal$150.00
INV-1044UnpaidBank transfer$350.00
INV-1045PaidCredit card$450.00
INV-1046PaidPayPal$550.00
Total$1,750.00

Blocks

Ready-made variations composed from the base component with Motion. Each installs on its own and pulls in its dependencies automatically.

Data Table

Sorting, filtering, selection and pagination in one self-contained component — no TanStack Table. Click a header to cycle ascending, descending and off; the arrow flips between them. Rows that stay on screen glide to their new place, new rows fade in, and short pages pad with blank rows so the table never changes height. Pass a stable getRowId so rows can animate.

Recent payments
Ruby Silvaruby@harbor.dev
succeeded$1,290.00
Noah Kimnoah@orbit.app
failed$874.00
Mia Rossimia@lumen.so
succeeded$837.00
Zoe Martinzoe@pixel.co
succeeded$721.00
Nora Jensennora@fjord.co
succeeded$512.00

1 of 12 row(s) selected.

Page 1 of 3
$ npx shadcn@latest add https://duskui.com/r/data-table.json
PropTypeDefaultDescription
dataT[]—The rows. Required.
columnsDataTableColumn<T>[]—Column definitions: id, header, accessor, cell, sortable, filterable, filterValue, align, className. Required.
getRowId(row: T) => string—A stable id per row, used for selection and animation. Required.
captionstring—Accessible name, rendered as a visually hidden caption. Required.
pageSizenumber5Rows per page. 0 shows every row.
selectablebooleanfalseShow row checkboxes and a select-all checkbox for the page.
selectedIds / onSelectionChangestring[] / (ids: string[]) => void—Control the selection. Uncontrolled when left out.
filterablebooleantrueShow the filter input.
filterPlaceholderstring"Filter…"Placeholder and label of the filter input.
defaultSort{ id: string; direction: "asc" | "desc" }—The initial sort.
emptyMessageReactNode"No results."Shown when nothing matches the filter.
toolbarReactNode—Extra controls on the right of the toolbar.

Expandable Rows

Rows that open to reveal a detail panel — logs, line items, metadata. The chevron turns, the panel springs open from zero height and its content fades up, and the open row stays lit. Set single for accordion behavior.

Recent deployments
ExpandCommitStatusDuration
Add calendar month transitionsmain
Ready42s
Animate rows on sortfeat/data-table
Building18s
Defer platform label until mountfix/kbd-hydration
Error31s
  1. Install dependencies (passed)13s
  2. Type check (failed)18s
$ npx shadcn@latest add https://duskui.com/r/expandable-table.json
PropTypeDefaultDescription
data / columns / getRowIdT[] / ExpandableColumn<T>[] / (row: T) => string—Rows, columns (id, header, cell, align, className) and a stable id per row. Required.
renderDetail(row: T) => ReactNode—Content of the panel under an open row. Required.
captionstring—Accessible name, rendered as a visually hidden caption. Required.
singlebooleanfalseOnly one row open at a time.
defaultExpandedstring[][]Row ids that start open.
getExpandLabel(row: T) => string() => "Show details"Accessible label for each row's toggle button.

API Reference

Same parts as shadcn/ui, each a thin wrapper around the native element with a data-slot attribute: Table, TableHeader, TableBody, TableFooter, TableRow, TableHead, TableCell and TableCaption.

PropTypeDefaultDescription
containerClassNamestring—Table only. Classes for the horizontally scrolling wrapper, e.g. a border or max height.
data-state="selected"attribute—TableRow. Highlights the row and keeps its accent bar lit.

Accessibility

  • Real table markup throughout: <table>, <thead>, <th scope="col"> and a <caption> (visually hidden in the blocks) that names the table.
  • Sortable headers are buttons inside the <th>, and the header carries aria-sort (ascending, descending or none) so the current order is announced.
  • Every checkbox has a label ("Select all rows on this page", "Select row 3"), and the selection and page counts are polite live regions.
  • Expand toggles are buttons with aria-expanded and aria-controls pointing at the open detail row.
  • Under prefers-reduced-motion rows swap and panels open instantly, and the sort arrow flips without spinning.