Skip to content
Pixelbits
Docs / Table
Data display

Table

A data table: semantic <table> markup with the kit's styling, in a container that scrolls horizontally on small screens. Compose it from TableHeader, TableBody, TableRow, TableHead and TableCell.

ComponentGroup
Pixel buttonSignature2.0
Command paletteOverlay3.2
SelectForm3.9

Installation

npm: import
import { Table, TableHeader, TableBody, TableRow, TableHead, TableCell } from "pixelbits/table";
shadcn: copy the source
npx shadcn add https://pixelbits.ali-moradi-develop.com/r/table.json

API

<Table>

A data table: semantic <table> markup with the kit's styling, in a container that scrolls horizontally on small screens. Compose it from TableHeader, TableBody, TableRow, TableHead and TableCell.

Example
<Table>
  <TableHeader><TableRow><TableHead>Component</TableHead><TableHead numeric>kB</TableHead></TableRow></TableHeader>
  <TableBody><TableRow><TableCell>Button</TableCell><TableCell numeric>2.0</TableCell></TableRow></TableBody>
</Table>
PropTypeDefaultDescription
density"compact" | "comfortable""comfortable"

Row height: "compact" for dense data, "comfortable" for reading.

wrapperClassNamestring—

Classes for the scroll container around the table.

Also accepts every prop of TableHTMLAttributes<HTMLTableElement>.

<TableHeader>

The header row group (<thead>).

<TableBody>

The body (<tbody>).

<TableRow>

A row (<tr>). Rows highlight on hover.

PropTypeDefaultDescription
selectedbooleanfalse

Highlight the row as selected (also sets aria-selected).

Also accepts every prop of HTMLAttributes<HTMLTableRowElement>.

<TableHead>

A column header (<th scope="col">), optionally sortable.

PropTypeDefaultDescription
numericbooleanfalse

Right-align (end-align in RTL) for numbers.

sort"ascending" | "descending" | "none"—

Makes the header a sort button and announces the order with aria-sort. "none" means sortable but not sorted.

onSort() => void—

Called when the sort button is pressed.

childrenReactNode—

The header text.

Also accepts every prop of ThHTMLAttributes<HTMLTableCellElement>.

<TableCell>

A data cell (<td>).

PropTypeDefaultDescription
numericbooleanfalse

Right-align (end-align in RTL) and use tabular mono digits.

Also accepts every prop of TdHTMLAttributes<HTMLTableCellElement>.