CraftUI

Table

A data table drawn as Ore UI list rows, with selection, sorting, and empty and loading rows.

1 of 4 servers selected
ServerStatus
The HiveOnline3,120
LifeboatOnline1,824
MinevilleOnline952
GalaxiteOffline0

Installation

npx shadcn@latest add @runqora/craft-table

Usage

import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from "@/components/craft/table";

<Table>
  <TableHeader>
    <TableRow>
      <TableHead>World</TableHead>
      <TableHead>Mode</TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    <TableRow>
      <TableCell>Harbor</TableCell>
      <TableCell>Survival</TableCell>
    </TableRow>
  </TableBody>
</Table>;

Examples

Empty and loading

TableEmpty and TableLoading are whole rows. Set colSpan to the number of columns.

WorldModeLast played
No worlds yet. Create one to start.
WorldModeLast played
Loading worlds

Props

TableHead

Prop

Type

TableRow

Prop

Type

Accessibility

  • It's a real HTML table, so screen readers can move by row and column and read each cell's heading.
  • A sortable heading holds a button, and the heading's aria-sort says how the column is sorted.
  • Selection is a Checkbox in each row, named after the row. Selected rows have a green bar as well as their color.
  • TableLoading is a status, so screen readers announce it.

Customization

Wide tables scroll sideways inside their frame. The table renders on the server; sorting needs an onSort handler, so a sortable table lives in a client component.

Dependencies

  • shadcn's utils, and craft-theme

Source

On this page