Table
FreeRows and columns for data people read: invoices, members, usage. Plain and read-only, with ready-made cells for people, status, money and actions.
npx wunderui-cli add tablePlayground
| Invoice | Status | Customer | Amount |
|---|---|---|---|
| INV-2041 | Paid | WunderUI | $24,800.00 |
| INV-2040 | Open | Halcyon Labs | $3,200.00 |
| INV-2039 | Overdue | Pergola Foods | $980.00 |
| INV-2038 | Paid | Marlow & Finch | $12,400.00 |
| Invoice | Status | Customer | Amount |
|---|---|---|---|
| INV-2041 | Paid | WunderUI | $24,800.00 |
| INV-2040 | Open | Halcyon Labs | $3,200.00 |
| INV-2039 | Overdue | Pergola Foods | $980.00 |
| INV-2038 | Paid | Marlow & Finch | $12,400.00 |
| Invoice | Status | Customer | Amount |
|---|---|---|---|
| INV-2041 | Paid | WunderUI | $24,800.00 |
| INV-2040 | Open | Halcyon Labs | $3,200.00 |
| INV-2039 | Overdue | Pergola Foods | $980.00 |
| INV-2038 | Paid | Marlow & Finch | $12,400.00 |
| Invoice | Status | Customer | Amount |
|---|---|---|---|
| INV-2041 | Paid | WunderUI | $24,800.00 |
| INV-2040 | Open | Halcyon Labs | $3,200.00 |
| INV-2039 | Overdue | Pergola Foods | $980.00 |
| INV-2038 | Paid | Marlow & Finch | $12,400.00 |
| Total | Sum$41,380.00 |
| Invoice | Status | Customer | Amount |
|---|---|---|---|
| INV-2041 | Paid | WunderUI | $24,800.00 |
| INV-2040 | Open | Halcyon Labs | $3,200.00 |
| INV-2039 | Overdue | Pergola Foods | $980.00 |
| INV-2038 | Paid | Marlow & Finch | $12,400.00 |
| Total | Sum$41,380.00 |
| Invoice | Status | Customer | Amount |
|---|---|---|---|
| INV-2041 | Paid | WunderUI | $24,800.00 |
| INV-2040 | Open | Halcyon Labs | $3,200.00 |
| INV-2039 | Overdue | Pergola Foods | $980.00 |
| INV-2038 | Paid | Marlow & Finch | $12,400.00 |
| Total | Sum$41,380.00 |
Installation
npx wunderui-cli add tableWrites the source into your project with its dependencies and, on first use, the styles - see Installation.
Then import what you need:
import {
Table,
TableBody,
TableCaption,
TableCell,
TableFooter,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table"Then use it:
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"
export function Invoices() {
return (
<div className="overflow-hidden rounded-xl border border-border bg-card">
<Table aria-label="Recent invoices">
<TableHeader>
<TableRow>
<TableHead>Invoice</TableHead>
<TableHead className="text-right">Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableCell>INV-2041</TableCell>
<TableCell className="text-right tabular-nums">$24,800.00</TableCell>
</TableRow>
</TableBody>
</Table>
</div>
)
}Expected result: A card with a quiet header row reading Invoice and Amount, and one row: INV-2041 in the text colour and $24,800.00 on the right. The row lightens on hover.
When to use
Use Table for
- Rows people read and compare: invoice line items, a list of members, usage per product
- A short, fixed set of columns where every row has the same shape
- A summary row that closes the table with a named total
Use something else for
- Data Table for sorting, filters, bulk actions, column settings and server-side data
- List Group for rows without columns, such as an activity list or a settings list
Cells
Tables repeat a few shapes, so UserCell, CompanyCell, CurrencyCell, ActionIconsCell and the rest are ready pieces for a TableCell. Every table then shows a person or an amount the same way.
| Member | Role |
|---|---|
NL Nora Lindgreninfo@wunderui.com | Owner |
DO Daniel Okafor | Admin |
PR Priya Raman | Member |
| Workspace | Plan |
|---|---|
Docsdocs.wunderui.com | Team |
Dashboardapp.wunderui.com | Business |
Status pagestatus.wunderui.com | Team |
| Product | Type |
|---|---|
Analytics dashboardWUI-AD-01 | Dashboard |
CheckoutWUI-CO-02 | Commerce |
CalendarWUI-CA-03 | Data |
| Plan | Revenue | Visits |
|---|---|---|
| Solo | $9,250.00 | 6,410+4.1% |
| Team | $18,400.00 | 1,842+12.4% |
| Business | $24,900.00 | 932-2.3% |
| Project | Status | Progress |
|---|---|---|
| Website relaunch | On track | 70% |
| Mobile app | At risk | 48% |
| Docs migration | Done | 100% |
| Invoice | Links | Edit | Pay |
|---|---|---|---|
| INV-2041 | |||
| INV-2040 | |||
| INV-2039 |
Selection
Table draws a selection, a row marked selected turns subtle, but does not keep it. Put a Checkbox in the first column, and use Data Table for select-all and bulk actions.
| Member | Role | |
|---|---|---|
| Nora Lindgren | Owner | |
| Daniel Okafor | Admin | |
| Priya Raman | Member | |
| Tomás Ferreira | Member |
| Plan | Price per month | Seats |
|---|---|---|
| $29 | 1 seat | |
| $79 | Up to 15 seats | |
| $199 | Unlimited seats |
Density
Row padding and header height come from the density tokens, so setting comfortable density on the table or any ancestor changes them. Compact is the default.
| Member | Role | Status |
|---|---|---|
| Nora Lindgren | Owner | Active |
| Daniel Okafor | Admin | Active |
| Priya Raman | Member | Active |
| Tomás Ferreira | Member | Invited |
| Member | Role | Status |
|---|---|---|
| Nora Lindgren | Owner | Active |
| Daniel Okafor | Admin | Active |
| Priya Raman | Member | Active |
| Tomás Ferreira | Member | Invited |
Width
Cells do not wrap, so a table wider than its card scrolls inside it and takes focus so the arrow keys can scroll. Let a text column wrap where you want it to.
| Invoice | Customer | Amount |
|---|---|---|
| INV-2041 | WunderUI | $24,800.00 |
| INV-2040 | Halcyon Labs | $3,200.00 |
| INV-2039 | Pergola Foods | $980.00 |
| Customer | Company | Plan | Seats | MRR | Last active |
|---|---|---|---|---|---|
| Nora Lindgren | WunderUI | Team | 12 | $1,170 | 2 min ago |
| Daniel Okafor | Halcyon Labs | Business | 40 | $4,900 | 1 h ago |
| Priya Raman | Pergola Foods | Solo | 1 | $29 | Yesterday |
| Invoice | Customer | Amount |
|---|---|---|
| INV-2041 | WunderUI Design Systems and Brand Team | $24,800.00 |
| INV-2040 | Halcyon Labs Europe | $3,200.00 |
| INV-2039 | Pergola Foods | $980.00 |
States
A table has no loading, empty or error state of its own. Keep the header, and put skeleton rows, an empty state or an error with Retry where the rows go.
| Invoice | Customer | Amount |
|---|---|---|
| INV-2041 | WunderUI | $24,800.00 |
| INV-2040 | Halcyon Labs | $3,200.00 |
| INV-2039 | Pergola Foods | $980.00 |
| Invoice | Customer | Amount |
|---|---|---|
Loading invoices
| Invoice | Customer | Amount |
|---|
No invoices yet
Invoices appear here once you send your first one.
| Invoice | Customer | Amount |
|---|
Invoices could not be loaded
Check your connection and try again.
Keyboard interactions
A table isn't a widget, so rows and cells take no focus and have no key commands. Keys work on the scroll region and on the controls in your cells.
- TaborShift+Tab
- Moves focus to the next or previous control in a cell: a checkbox, a button, a link or a select. When the table is wider than its card, the scroll region is the first stop.
- ArrowLeftorArrowRight
- On the focused scroll region: scrolls the table sideways. ArrowUp and ArrowDown scroll it vertically when it has a fixed height.
- Space
- Ticks or clears a focused checkbox, or picks a focused radio. The row turns subtle with it.
- EnterorSpace
- Presses a focused button, such as an icon action or the call to action of a row.
Behavior and motion
What the table does with its rows, columns, width and motion.
- Native table
- Table renders a real table inside a scroll box, so screen readers announce rows, columns and headers. Headings are real th cells and the caption is a real caption.
- Row colours
- The header row has the page background. A row lightens on hover, a selected row stays subtle even on hover, and a row with an open menu keeps its hover colour.
- Primary column
- The first cell of a row is in the text colour and the others are secondary, so the eye lands on the name. A leading checkbox or expand button doesn't count, and you can mark another cell as primary.
- Alignment
- Text is left-aligned and numbers are right-aligned with tabular figures, in the cells and the heading above them. A column keeps one alignment from top to bottom.
- Summary row
- The footer closes the table with a line and medium weight. Its first cell names what the row adds up, and the figure sits right-aligned in its column.
- Caption
- The caption sits below the rows by default, and caption-top moves it above. When the page already names the table, hide the caption visually: it stays the accessible name.
- Width
- Cells don't wrap. A table wider than its container scrolls inside it and the scroll box takes focus, and you can let a text column wrap where you want.
- Density
- Header height and row padding follow the density setting. A one-line row is about 33 px by default, and comfortable density makes both larger.
- Missing values
- A value that doesn't exist is an em dash, never 0 and never an empty cell. Hide the dash from screen readers and give them the words No value.
- Loading, empty and error
- The table has no states of its own. Keep the header and put skeleton rows, an empty state or an error with a Retry button where the rows go, marked busy while loading.
- Motion
- Nothing moves. Rows change background on hover and selection, and icon actions change colour, all with short fades.
- Reduced motion
- There is no movement to remove, so reduced motion changes nothing. The short colour fades stay.
Anatomy
The figure marks the invoice table with its caption above the rows and a summary row at the foot. The ready-made cells follow the main parts and go inside a TableCell.
| Invoice | Status | Amount |
|---|---|---|
| INV-2041 | Paid | $24,800.00 |
| INV-2040 | Open | $3,200.00 |
| INV-2039 | Overdue | $980.00 |
| INV-2038 | Paid | $12,400.00 |
| Total | Sum$41,380.00 |
- data-slot="table-container"
A scroll box around the native table. When the table is too wide it scrolls sideways and takes focus so arrow keys can scroll it, and an aria-label names that region.
- data-slot="table"
The native table element. Your className goes here.
- 1data-slot="table-caption"Optional
The table's title, read first by screen readers. It sits below the rows by default, above them with caption-top, and can be hidden when a heading already names the table.
- 2data-slot="table-header"
The column headings. It has the page background, so the heading row reads as a quiet band above the rows.
- 3data-slot="table-head"
One column heading. Right-align it over a column of numbers.
- data-slot="table-body"
The data rows.
- 4data-slot="table-row"
One row. It lightens on hover and turns subtle when selected, and has no focus ring because it isn't interactive.
- 5data-slot="table-cell"
One cell. The first cell of a row is primary text and the rest are secondary, and it holds plain text or a ready-made cell.
- Optional
A row of icon actions such as edit, view and delete.
- Optional
A row of text actions, with quieter ones for the less common choices.
- Optional
A street over a city, on two lines.
- Optional
A checkbox in front of the row label, for picking rows.
- Optional
A logo square, the company name and its domain.
- Optional
The filled call to action of a row.
- Optional
An amount with its currency.
- Optional
A drag handle in front of the row label.
- Optional
A column label for a heading cell.
- Optional
An icon beside a label.
- Optional
A figure with its change, green when it is good news.
- Optional
A thumbnail, the product name and its SKU.
- Optional
A radio button in front of the row label, for picking one row.
- Optional
A label with a cross to remove it.
- Optional
Plain cell text in the table's text style.
- Optional
Like UserCell, but always with an avatar image or initials.
- Optional
A name over an email address, with an avatar or a person icon.
- 6data-slot="table-footer"Optional
A summary row, such as a named total. It is set in medium weight and closed off from the rows by a line.
Best practices
- Do
Name the table with a caption, or with an aria-label when the page heading already does. On a table that scrolls sideways, that name also labels the scroll region.
- Do
Right-align numbers, heading included, and use tabular figures so they line up and don't shift when they change. Text stays left.
- Do
Give amounts and quantities their unit. CurrencyCell adds the currency, and for other figures the column heading names the unit.
- Do
Show a missing value as an em dash and give screen readers the words No value. An empty cell looks like a mistake, and a 0 claims something the data doesn't.
- Do
Keep the header while the table loads, is empty or fails, and show the state where the rows go. The columns stay put, so nothing jumps when rows arrive.
- Don’t
Don't set row padding or heights by hand. Rows follow the density setting.
- Don’t
Don't make a row clickable when nothing inside it is. A row has no focus ring or key action, so put a link or button in the first cell.
- Don’t
Don't stack many columns on a phone. A sideways scroll hides the right-hand columns, so pick the few that matter or use a list.
- Don’t
Don't build sorting, filters or paging by hand around a Table. When people need them, use Data Table, which keeps that state for you.
API reference
Table and its parts each render the element they are named after and take its attributes, className, a ref and aria or data attributes. Only Table and the ready-made cells add props.
A scroll box around the native table. When the table is too wide it scrolls sideways and takes focus so arrow keys can scroll it, and an aria-label names that region.
The table's title, read first by screen readers. It sits below the rows by default, above them with caption-top, and can be hidden when a heading already names the table.
The column headings. It has the page background, so the heading row reads as a quiet band above the rows.
One column heading. Right-align it over a column of numbers.
The data rows.
One row. It lightens on hover and turns subtle when selected, and has no focus ring because it isn't interactive.
One cell. The first cell of a row is primary text and the rest are secondary, and it holds plain text or a ready-made cell.
A summary row, such as a named total. It is set in medium weight and closed off from the rows by a line.
A row of icon actions such as edit, view and delete.
| Prop | Type | Default | Description |
|---|---|---|---|
| actions required | { icon: ReactNode; label: string; onClick?: () => void }[] | — | The icon actions of the row, in order. Each has an , a that names the button for screen readers (include the row, such as ) and an optional . They turn the link colour on hover. |
A row of text actions, with quieter ones for the less common choices.
| Prop | Type | Default | Description |
|---|---|---|---|
| actions required | { label: string; onClick?: () => void; muted?: boolean }[] | — | The text actions of the row, in order. Each has a and an optional ; sets a quieter action for the less common choices. |
A street over a city, on two lines.
| Prop | Type | Default | Description |
|---|---|---|---|
| street required | string | — | The first line, in the text colour. |
| city | string | — | The second line, in the secondary colour. Leave it out for a one-line address. |
A checkbox in front of the row label, for picking rows.
| Prop | Type | Default | Description |
|---|---|---|---|
| checked | boolean | — | Whether the checkbox is ticked. It is a controlled value: update it in . |
| children | ReactNode | — | The label beside the checkbox. Leave it out for a bare checkbox and name it with on a Checkbox instead. |
| onCheckedChange | (checked) => void | — | Called with the new checked state when the checkbox or its label is pressed. |
A logo square, the company name and its domain.
| Prop | Type | Default | Description |
|---|---|---|---|
| name required | string | — | The company name, on the first line. |
| domain | string | — | The second line, usually the website of the company. Leave it out for a one-line cell. |
| logoSrc | string | — | The image of the logo square, 32 px with 8 px corners. Without it the square is an empty tint. |
The filled call to action of a row.
| Prop | Type | Default | Description |
|---|---|---|---|
| children required | ReactNode | — | The label of the button. It is a filled small button, the call to action of the row. |
| onClick | () => void | — | Called when the button is pressed. |
An amount with its currency.
| Prop | Type | Default | Description |
|---|---|---|---|
| value required | number | — | The amount as a number. It is shown with two decimals and a thousands separator, such as . |
| currency | string | "$" | The currency symbol written before the amount. Default . |
A drag handle in front of the row label.
| Prop | Type | Default | Description |
|---|---|---|---|
| children required | ReactNode | — | The label beside the drag handle. The handle is a grip icon; the cell draws it but does not move rows by itself. |
A column label for a heading cell.
| Prop | Type | Default | Description |
|---|---|---|---|
| children required | ReactNode | — | The text of the column label, set small and semibold in the secondary colour. |
| className | string | — | Extra classes for the label, for example over a column of numbers. |
An icon beside a label.
| Prop | Type | Default | Description |
|---|---|---|---|
| icon required | ReactNode | — | The icon before the label, drawn 20 px in the text colour. Pass a Lucide icon. |
| children required | ReactNode | — | The label beside the icon. |
A figure with its change, green when it is good news.
| Prop | Type | Default | Description |
|---|---|---|---|
| value required | string | — | The figure, in semibold, such as . Pass it already formatted. |
| delta | string | — | The change beside the figure, such as . Leave it out to show the figure alone. |
| good | boolean | true | Whether the change is good news. sets the delta green and is the default; sets it red, for a drop that matters or a rise that hurts. |
A thumbnail, the product name and its SKU.
| Prop | Type | Default | Description |
|---|---|---|---|
| name required | string | — | The product name, on the first line. |
| sku | string | — | The second line, such as the SKU. Leave it out for a one-line cell. |
| imageSrc | string | — | The image of the 32 px thumbnail with 8 px corners. Without it the square is an empty tint. |
A radio button in front of the row label, for picking one row.
| Prop | Type | Default | Description |
|---|---|---|---|
| value required | string | — | The value this row stands for. The radio is checked when it equals . |
| children | ReactNode | — | The label beside the radio. |
| selected | string | — | The value of the chosen row. It is a controlled value: update it in . |
| onSelect | (value) => void | — | Called with the of the row the person picked. |
A label with a cross to remove it.
| Prop | Type | Default | Description |
|---|---|---|---|
| label required | string | — | The text of the tag. |
| color | "indigo" | "blue" | "purple" | "pink" | "red" | "orange" | "yellow" | "green" | "alternative" | "grey" | "black" | "white" | "indigo" | The colour of the tag, one of the badge colours. Default . |
| onRemove | () => void | — | Shows a cross after the label and is called when it is pressed. Without it the tag cannot be removed. |
Plain cell text in the table's text style.
| Prop | Type | Default | Description |
|---|---|---|---|
| children required | ReactNode | — | The cell text, set in the secondary colour. |
| className | string | — | Extra classes for the text. |
Like UserCell, but always with an avatar image or initials.
| Prop | Type | Default | Description |
|---|---|---|---|
| name required | string | — | The name, on the first line. |
| string | — | The second line, usually the email address. Leave it out for a one-line cell. | |
| initials | string | — | The letters shown in the avatar. Without them the first two letters of the name are used. |
| avatarSrc | string | — | The image of the avatar. Without it the initials show. |
| avatarSize | "sm" | "xs" | "default" | "lg" | — | The size of the avatar: , , (36 px) or . Default ; use for the two-line cell. |
A name over an email address, with an avatar or a person icon.
| Prop | Type | Default | Description |
|---|---|---|---|
| name required | string | — | The name, on the first line. |
| string | — | The second line, usually the email address. Leave it out for a one-line cell. | |
| initials | string | — | The letters shown in the avatar. Without them the first two letters of the name are used. |
| avatarSrc | string | — | The image of the avatar. Without it the initials show. |
| avatarSize | "sm" | "xs" | "default" | "lg" | "sm" | The size of the avatar: , , (36 px) or . Default ; use for the two-line cell. |
Notes for AI
Give your coding assistant the Markdown reference instead of screenshots.
get_component("table")npx wunderui-cli add tableThe full library index for assistants is at /llms.txt.
Related components
- 14 rows
INV-2001 Nora Lindgren Paid Pro $299 INV-2002 Daniel Okafor Pending Core $398 INV-2003 Priya Raman Paid Core $597 INV-2004 Tomás Ferreira Overdue Pro $299 INV-2005 Maya Kessler Paid Core $398 0 of 14 rows selectedRows per pageData & Tables11 stylesProData TableA data table on TanStack Table: sort on several columns, filter from the column definitions, select rows with a floating action bar, expand, pin, resize columns, page and export to CSV, and show rows as cards on small screens, with controlled state for server-side data. - 3
Team
- NLNora LindgrenOwnerOwner
- DODaniel OkaforEngineeringAdmin
- PRPriya RamanDesignMember
Data & Tables8 stylesProList GroupA 400 px card of list rows with an optional header — sixteen ready patterns: basic, icon, avatar, brand, metric, selectable, toggle, sortable, expandable, grouped, ranking, comparison, tree, action, discussion and master–detail.