Early bird: 30% off Dashral ProSee pricing

Dashral

Table

Table with motion: when its rows change, they move instead of jumping. A sort glides each row to its new place, a row that goes fades out while the rest close up, and a new one fades in, tinted for a moment.

$ pnpm dlx shadcn@latest add @dashral/motion-table
A list of your recent invoices. Sort by amount to see the rows move.
InvoiceStatusMethod
INV-001PaidCredit card$250
INV-002PendingPayPal$150
INV-003UnpaidBank transfer$350
INV-004PaidCredit card$450
INV-005PaidPayPal$550
Total$1750

Installation

$ pnpm dlx shadcn@latest add @dashral/motion-table

Adds components/dashral/motion/table.tsx, the Table it builds on (in components/dashral/), motion and the motion files every motion component shares. Or by its full URL: https://dashral.com/r/motion-table.json

Usage

The same as Table, imported from components/dashral/motion/ (with the npm package: @dashral/motion/components/table): swap the import and it moves.

example.tsx
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/dashral/motion/table"

<Table>
  <TableHeader>
    <TableRow>
      <TableHead>Customer</TableHead>
      <TableHead className="text-right">Total</TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    {orders.map((order) => (
      <TableRow key={order.id}>
        <TableCell>{order.customer}</TableCell>
        <TableCell className="text-right">{order.total}</TableCell>
      </TableRow>
    ))}
  </TableBody>
</Table>

Examples

Orders to ship

New order slides in at the top, tinted for a moment; Ship takes a row out and the rest close up; Prioritize moves a row to the top.

3 to ship

OrderCustomerItemsTotalActions
#1042Jackson LeePriority1$39
#1041Olivia Martin3$128
#1043Isabella Nguyen5$246

Compared with Default

Default

Rows appear, move and disappear at once when the data changes.

Motion

Rows glide to a new place when the order changes, fade out while the rest close up, and new ones fade in, tinted for a moment.

How the two editions differ in general, and which to use where: Motion.

API reference

Every prop of Table, and every attribute of the element it renders. What the Motion edition adds is marked Motion.

Table, TableHeader, TableBody, TableFooter, TableRow, TableHead, TableCell, TableCaption

Styled table elements; the table scrolls sideways when it doesn't fit.

Also takes every prop of <table>(opens in a new tab).

TableBodyMotion

PropTypeDefault
highlightNewboolean

Rows that arrive after the table first drew are tinted in the primary color for a moment, so the eye finds them.

true

Table, TableHeader, TableFooter, TableHead, TableCell and TableCaption are the default edition's, re-exported. Give each TableRow a stable key (the record's id), or React can't tell which row moved.

Motion

  • When the order changes (a sort, a row moved to the top), each row glides to its new place in 0.35s on a smooth curve, no spring.
  • A row that goes fades out in 0.18s, then the rows under it glide up to close the gap.
  • A row that arrives fades in from 6px above, and a tint of the primary color over it fades away over 1.4s; hover and selected still show under the tint. highlightNew turns the tint off.
  • The first draw stays still, and rows in the header and footer never move. With reduced motion, rows only fade in and out.