Table
Data tables in two styles: Workspace inside the opportunity and contact workspaces (36 px header, 40 px rows, 13 px, in a bordered shell), and Main for the contacts and opportunities lists (32 px uppercase header, 45 px rows, 14 px). Group headers band the rows under them.
BetaReady to use. Its API can still change in a minor release; the changelog says when.
import { Table, TableHeader, TableBody, TableRow, TableHead, TableCell, TableGroupHeader, TableGroupRows } from "@leap-crm/design-system";Playground
Change a prop and the component follows. Its code is under Props.
| Name | Role |
|---|---|
| Ada Hartley | Client |
| Ben Okafor | Other side |
Props
Best practices
When to use it, and the rules that apply in particular places.
| Guidance | Practice |
|---|---|
| Do | Use variant="workspace" for a table inside the opportunity or contact workspace, and main for the full contacts and opportunities lists. |
| Do | Group rows with TableGroupHeader and TableGroupRows, like documents by folder. Use dotClassName for a role colour, so the colour stays a small dot beside the name and count. |
| Do | Wrap a long value, like a matter name or an email, in Truncate so the cell keeps its width and the full value shows on hover. |
| Do | Show an empty cell with EmptyValue, never a blank or "N/A". |
| Don't | Set animated on a long table that re-renders often. Every animated row is measured on each render. |
| Don't | Tint a row's background in its status colour. Put the status in a Badge in its own cell, so colour stays an accent and the row stays readable. |
Props
Each part takes every prop of its HTML element: table, thead, tbody, tr, th and td.
Table
| Prop | Type | Default | Description |
|---|---|---|---|
| variant | "workspace" | "main" | "workspace" | Workspace for tables inside the opportunity and contact workspaces: 36 px header, 40 px rows, 13 px text, in a bordered shell. Main for the contacts and opportunities lists: 32 px uppercase header, 45 px rows, 14 px. |
| tableClassName | string | — | Classes for the <table> itself; className sizes and places the whole table, shell included. |
TableGroupHeader
| Prop | Type | Default | Description |
|---|---|---|---|
| title * | ReactNode | — | The group's name, like a stage or a date. |
| count | number | — | How many rows the group holds, in a small count after the title. |
| dotClassName | string | — | An 8 px dot before the title, coloured by a background class, like a relationship side's colour. |
| open * | boolean | — | Whether the group's rows show. |
| onOpenChange * | (open: boolean) => void | — | Runs when it opens or closes, with whether it's now open. |
| colSpan * | number | — | How many columns the band spans. |
TableGroupRows
| Prop | Type | Default | Description |
|---|---|---|---|
| open * | boolean | — | Whether the rows show: pass the same value as the group's header. |
| children * | ReactNode | — | The group's TableRows. Render them whether open or not. |
Code
What the playground shows, ready to copy.
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@leap-crm/design-system";
<Table>
<TableHeader>
<TableRow>
<TableHead>Name</TableHead>
<TableHead>Role</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableCell>Ada Hartley</TableCell>
<TableCell>Client</TableCell>
</TableRow>
<TableRow>
<TableCell>Ben Okafor</TableCell>
<TableCell>Other side</TableCell>
</TableRow>
</TableBody>
</Table>Rows arriving and leaving
TableBody animated: a new row slides in with a brief tint, a removed one fades and the rows below glide up, and re-sorted rows glide to their places. Rows there on first render stay still. Key each row by its record. Every animated row is measured when the body re-renders, so leave it off for long tables that re-render often.
| Name | Role |
|---|---|
| Jane Citizen | Purchaser |
| John Citizen | Purchaser |
| Paddington Realty | Agent |
Group headers
A 28 px band with the group's title and count; the chevron points down while open and right while closed. Press it to fold the group: its rows, wrapped in TableGroupRows, ease shut on the resize curve and stay in the table, so the columns keep their widths and no heading moves. Render the rows whether open or not.
| Name | Added |
|---|---|
Statement of claim.pdf | 2 Nov |
Defence.pdf | 2 Nov |
What the examples share
The imports and the scaffolding the examples above call. The scaffolding lives in this page, not in the library.
import { Button, Table, TableBody, TableCell, TableGroupHeader, TableGroupRows, TableHead, TableHeader, TableRow } from "@leap-crm/design-system";
import { Fragment, useState } from "react";
const contacts = [
["Jane Citizen", "Purchaser", "jane@citizen.com.au"],
["John Citizen", "Purchaser", "john@citizen.com.au"],
["Paddington Realty", "Agent", "sales@paddington.com.au"],
] as const;
const folders = [
{ name: "Pleadings", files: ["Statement of claim.pdf", "Defence.pdf"] },
{ name: "Correspondence", files: ["Letter to other side.docx"] },
] as const;
const parties = [
["Jane Citizen", "Purchaser"],
["John Citizen", "Purchaser"],
["Paddington Realty", "Agent"],
["Harbour Bank", "Lender"],
["Lee & Co Lawyers", "Other side"],
] as const;
function LiveTable() {
const [rows, setRows] = useState(parties.slice(0, 3));
const next = parties.find(party => !rows.includes(party));
return (
<div className="flex flex-col gap-3">
<div className="flex gap-2">
<Button
intent="outline"
size="xs"
disabled={next === undefined}
onClick={() => next && setRows([...rows, next])}
>
Add
</Button>
<Button
intent="outline"
size="xs"
disabled={rows.length === 0}
onClick={() => setRows(rows.slice(1))}
>
Remove first
</Button>
<Button
intent="outline"
size="xs"
onClick={() =>
setRows(rows.toSorted((a, b) => a[0].localeCompare(b[0]) * -1))
}
>
Sort Z–A
</Button>
</div>
<Table>
<TableHeader>
<TableRow>
<TableHead>Name</TableHead>
<TableHead>Role</TableHead>
</TableRow>
</TableHeader>
<TableBody animated>
{rows.map(([name, role]) => (
<TableRow key={name}>
<TableCell>{name}</TableCell>
<TableCell>{role}</TableCell>
</TableRow>
))}
</TableBody>
</Table>
</div>
);
}
function Grouped() {
const [open, setOpen] = useState<Record<string, boolean>>({
Pleadings: true,
});
return (
<Table className="w-130">
<TableHeader>
<TableRow>
<TableHead>Name</TableHead>
<TableHead>Added</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{folders.map(folder => (
<Fragment key={folder.name}>
<TableGroupHeader
title={folder.name}
count={folder.files.length}
open={open[folder.name] ?? false}
onOpenChange={next =>
setOpen(current => ({ ...current, [folder.name]: next }))
}
colSpan={2}
/>
<TableGroupRows open={open[folder.name] ?? false}>
{folder.files.map(file => (
<TableRow key={file}>
<TableCell>{file}</TableCell>
<TableCell>2 Nov</TableCell>
</TableRow>
))}
</TableGroupRows>
</Fragment>
))}
</TableBody>
</Table>
);
}Keyboard
The keys it answers to. Tab moves between components, arrows move within them.
| Keys | What they do |
|---|---|
| EnterSpace | Open or close the focused group header. |







