Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Table Extras

ProNew

Three additions to the table: a handle that resizes a column by dragging or with the arrow keys, a heading row that folds a group of rows away, and row selection with Shift-click ranges.

Installation

pnpm dlx shadcn@latest add @viewport/table-extras

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

<ColumnResizer>

PropTypeDefault
width*number

The column's width now, in pixels.

—
onWidthChange*(width: number) => void—
minnumber72
maxnumber640
label*string

The column's name, for the handle's accessible name.

—
onReset() => void

Runs on a double click, e.g. to return the column to its default width.

—

<TableGroupRow>

PropTypeDefault
label*React.ReactNode

The group's name, e.g. the value the rows share.

—
countnumber

How many rows are in the group.

—
colSpan*number

How many columns the table has, so the heading spans them all.

—
open*boolean—
onOpenChange*(open: boolean) => void—
summaryReact.ReactNode

Shown at the end of the heading, e.g. a total for the group.

—

Accessibility

  • The resize handle is a separator with a value, arrow-key steps, Home and End.
  • Group headings are buttons that report whether the group is open.
  • Range selection works from the keyboard with Shift and Space.
  • Respects prefers-reduced-motion.