# Table

Rows and columns with 23 ready-made cell types; for sorting and search use Data Table.

- Category: Core Elements
- Page: https://wunderui.com/components/table
- Tier: Free

## Install

```bash
npx wunderui-cli add table
```

## Import

```tsx
import { Table, ActionIconsCell, ActionItemsCell, AddressCell, CheckItemCell, CompanyCell, CTAButtonCell, CurrencyCell, DragItemCell, HeadingCell, IconTextCell, PerformanceCell, ProductCell, RadioItemCell, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, TagCell, TextCell, UserAvatarCell, UserCell } from "@/components/ui/table"
```

## Minimal usage

Then use it:

```tsx
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.

## Usage

```tsx
import { Badge } from "@/components/ui/badge"
import {
  Table,
  TableBody,
  TableCaption,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from "@/components/ui/table"

const STATUS = { Paid: "green", Open: "blue", Overdue: "red" } as const

const INVOICES = [
  { id: "INV-2041", status: "Paid", customer: "WunderUI", amount: 24800 },
  { id: "INV-2040", status: "Open", customer: "Halcyon Labs", amount: 3200 },
  { id: "INV-2039", status: "Overdue", customer: "Pergola Foods", amount: 980 },
  { id: "INV-2038", status: "Paid", customer: "Marlow & Finch", amount: 12400 },
] as const

const usd = (value: number) => value.toLocaleString("en-US", { style: "currency", currency: "USD" })

export function Example() {
  return (
    <div className="overflow-hidden rounded-xl border border-border bg-card">
      <Table className="caption-top">
        <TableCaption className="mt-0 px-4 py-3 text-left">
          <span className="block text-sm font-medium text-foreground">Recent invoices</span>
          <span className="block text-xs text-text-tertiary">Invoices issued in the last 30 days</span>
        </TableCaption>
        <TableHeader>
          <TableRow>
            <TableHead>Invoice</TableHead>
            <TableHead>Status</TableHead>
            <TableHead>Customer</TableHead>
            <TableHead className="text-right">Amount</TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          {INVOICES.map((invoice) => (
            <TableRow key={invoice.id}>
              <TableCell>{invoice.id}</TableCell>
              <TableCell>
                <Badge color={STATUS[invoice.status]} badgeStyle="light" shape="pill" size="sm">
                  {invoice.status}
                </Badge>
              </TableCell>
              <TableCell>{invoice.customer}</TableCell>
              <TableCell className="text-right tabular-nums">{usd(invoice.amount)}</TableCell>
            </TableRow>
          ))}
        </TableBody>
      </Table>
    </div>
  )
}
```

## 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

- [Data Table](https://wunderui.com/components/data-table) for sorting, filters, bulk actions, column settings and server-side data
- [List Group](https://wunderui.com/components/list-group) for rows without columns, such as an activity list or a settings list

## Keyboard

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.

| Key | Action |
|---|---|
| `Tab` or `Shift+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. |
| `ArrowLeft` or `ArrowRight` | 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. |
| `Enter` or `Space` | Presses a focused button, such as an icon action or the call to action of a row. |

## Behavior

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

- `Table`: 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.
- `Table element`: The native table element. Your className goes here.
- `TableCaption`: 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.
- `TableHeader`: The column headings. It has the page background, so the heading row reads as a quiet band above the rows.
- `TableHead`: One column heading. Right-align it over a column of numbers.
- `TableBody`: The data rows.
- `TableRow`: One row. It lightens on hover and turns subtle when selected, and has no focus ring because it isn't interactive.
- `TableCell`: 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.
- `TableFooter`: A summary row, such as a named total. It is set in medium weight and closed off from the rows by a line.
- `ActionIconsCell`: A row of icon actions such as edit, view and delete.
- `ActionItemsCell`: A row of text actions, with quieter ones for the less common choices.
- `AddressCell`: A street over a city, on two lines.
- `CheckItemCell`: A checkbox in front of the row label, for picking rows.
- `CompanyCell`: A logo square, the company name and its domain.
- `CTAButtonCell`: The filled call to action of a row.
- `CurrencyCell`: An amount with its currency.
- `DragItemCell`: A drag handle in front of the row label.
- `HeadingCell`: A column label for a heading cell.
- `IconTextCell`: An icon beside a label.
- `PerformanceCell`: A figure with its change, green when it is good news.
- `ProductCell`: A thumbnail, the product name and its SKU.
- `RadioItemCell`: A radio button in front of the row label, for picking one row.
- `TagCell`: A label with a cross to remove it.
- `TextCell`: Plain cell text in the table's text style.
- `UserAvatarCell`: Like UserCell, but always with an avatar image or initials.
- `UserCell`: A name over an email address, with an avatar or a person icon.

## 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.
- Right-align numbers, heading included, and use tabular figures so they line up and don't shift when they change. Text stays left.
- Give amounts and quantities their unit. CurrencyCell adds the currency, and for other figures the column heading names the unit.
- 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.
- 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 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 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 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

| Prop | Type | Default |
|---|---|---|


Also accepts React.TableHTMLAttributes attributes.

### ActionIconsCell

| Prop | Type | Default | Description |
|---|---|---|---|
| actions* | { icon: ReactNode; label: string; onClick?: () => void }[] |  | The icon actions of the row, in order. Each has an `icon`, a `label` that names the button for screen readers (include the row, such as `Edit INV-2041`) and an optional `onClick`. They turn the link colour on hover. |

### ActionItemsCell

| Prop | Type | Default | Description |
|---|---|---|---|
| actions* | { label: string; onClick?: () => void; muted?: boolean }[] |  | The text actions of the row, in order. Each has a `label` and an optional `onClick`; `muted: true` sets a quieter action for the less common choices. |

### AddressCell

| Prop | Type | Default | Description |
|---|---|---|---|
| street* | 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. |

### CheckItemCell

| Prop | Type | Default | Description |
|---|---|---|---|
| checked | boolean |  | Whether the checkbox is ticked. It is a controlled value: update it in `onCheckedChange`. |
| children | ReactNode |  | The label beside the checkbox. Leave it out for a bare checkbox and name it with `aria-label` on a Checkbox instead. |
| onCheckedChange | (checked: boolean) => void |  | Called with the new checked state when the checkbox or its label is pressed. |

### CompanyCell

| Prop | Type | Default | Description |
|---|---|---|---|
| name* | 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. |

### CTAButtonCell

| Prop | Type | Default | Description |
|---|---|---|---|
| children* | 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. |

### CurrencyCell

| Prop | Type | Default | Description |
|---|---|---|---|
| value* | number |  | The amount as a number. It is shown with two decimals and a thousands separator, such as `1,842.00`. |
| currency | string | "$" | The currency symbol written before the amount. Default `$`. |

### DragItemCell

| Prop | Type | Default | Description |
|---|---|---|---|
| children* | ReactNode |  | The label beside the drag handle. The handle is a grip icon; the cell draws it but does not move rows by itself. |

### HeadingCell

| Prop | Type | Default | Description |
|---|---|---|---|
| children* | ReactNode |  | The text of the column label, set small and semibold in the secondary colour. |
| className | string |  | Extra classes for the label, for example `text-right` over a column of numbers. |

### IconTextCell

| Prop | Type | Default | Description |
|---|---|---|---|
| children* | ReactNode |  | The label beside the icon. |
| icon* | ReactNode |  | The icon before the label, drawn 20 px in the text colour. Pass a Lucide icon. |

### PerformanceCell

| Prop | Type | Default | Description |
|---|---|---|---|
| value* | string |  | The figure, in semibold, such as `1,842`. Pass it already formatted. |
| delta | string |  | The change beside the figure, such as `+12.4%`. Leave it out to show the figure alone. |
| good | boolean | true | Whether the change is good news. `true` sets the delta green and is the default; `false` sets it red, for a drop that matters or a rise that hurts. |

### ProductCell

| Prop | Type | Default | Description |
|---|---|---|---|
| name* | string |  | The product name, on the first line. |
| imageSrc | string |  | The image of the 32 px thumbnail with 8 px corners. Without it the square is an empty tint. |
| sku | string |  | The second line, such as the SKU. Leave it out for a one-line cell. |

### RadioItemCell

| Prop | Type | Default | Description |
|---|---|---|---|
| value* | string |  | The value this row stands for. The radio is checked when it equals `selected`. |
| children | ReactNode |  | The label beside the radio. |
| onSelect | (value: string) => void |  | Called with the `value` of the row the person picked. |
| selected | string |  | The value of the chosen row. It is a controlled value: update it in `onSelect`. |

### TableBody

| Prop | Type | Default |
|---|---|---|


Also accepts React.HTMLAttributes attributes.

### TableCaption

| Prop | Type | Default |
|---|---|---|


Also accepts React.HTMLAttributes attributes.

### TableCell

| Prop | Type | Default |
|---|---|---|


Also accepts React.TdHTMLAttributes attributes.

### TableFooter

| Prop | Type | Default |
|---|---|---|


Also accepts React.HTMLAttributes attributes.

### TableHead

| Prop | Type | Default |
|---|---|---|


Also accepts React.ThHTMLAttributes attributes.

### TableHeader

| Prop | Type | Default |
|---|---|---|


Also accepts React.HTMLAttributes attributes.

### TableRow

| Prop | Type | Default |
|---|---|---|


Also accepts React.HTMLAttributes attributes.

### TagCell

| Prop | Type | Default | Description |
|---|---|---|---|
| label* | 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 `indigo`. |
| onRemove | () => void |  | Shows a cross after the label and is called when it is pressed. Without it the tag cannot be removed. |

### TextCell

| Prop | Type | Default | Description |
|---|---|---|---|
| children* | ReactNode |  | The cell text, set in the secondary colour. |
| className | string |  | Extra classes for the text. |

### UserAvatarCell

| Prop | Type | Default | Description |
|---|---|---|---|
| name* | string |  | The name, on the first line. |
| avatarSize | "sm" \| "xs" \| "default" \| "lg" |  | The size of the avatar: `xs`, `sm`, `default` (36 px) or `lg`. Default `sm`; use `default` for the two-line cell. |
| avatarSrc | string |  | The image of the avatar. Without it the initials show. |
| email | 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. |

### UserCell

| Prop | Type | Default | Description |
|---|---|---|---|
| name* | string |  | The name, on the first line. |
| avatarSize | "sm" \| "xs" \| "default" \| "lg" | "sm" | The size of the avatar: `xs`, `sm`, `default` (36 px) or `lg`. Default `sm`; use `default` for the two-line cell. |
| avatarSrc | string |  | The image of the avatar. Without it the initials show. |
| email | 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. |

## Examples

### Cells: the ready-made cell types

```tsx
import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
  UserCell,
} from "@/components/ui/table"

const MEMBERS = [
  { name: "Nora Lindgren", initials: "NL", email: "info@wunderui.com", role: "Owner" },
  { name: "Daniel Okafor", initials: "DO", role: "Admin" },
  { name: "Priya Raman", initials: "PR", role: "Member" },
]

export function Example() {
  return (
    <div className="overflow-hidden rounded-xl border border-border bg-card">
      <Table aria-label="Team members">
        <TableHeader>
          <TableRow>
            <TableHead>Member</TableHead>
            <TableHead>Role</TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          {MEMBERS.map((member) => (
            <TableRow key={member.name}>
              <TableCell>
                <UserCell name={member.name} initials={member.initials} email={member.email} avatarSize="default" />
              </TableCell>
              <TableCell>{member.role}</TableCell>
            </TableRow>
          ))}
        </TableBody>
      </Table>
    </div>
  )
}
```

### Selection: tick several rows or pick one

```tsx
import { useState } from "react"
import { Checkbox } from "@/components/ui/checkbox"
import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from "@/components/ui/table"

const MEMBERS = [
  { name: "Nora Lindgren", role: "Owner" },
  { name: "Daniel Okafor", role: "Admin" },
  { name: "Priya Raman", role: "Member" },
  { name: "Tomás Ferreira", role: "Member" },
]

export function Example() {
  const [selected, setSelected] = useState<string[]>(["Daniel Okafor"])
  const all = selected.length === MEMBERS.length

  return (
    <div className="overflow-hidden rounded-xl border border-border bg-card">
      <Table aria-label="Team members">
        <TableHeader>
          <TableRow>
            <TableHead className="w-10">
              <Checkbox
                aria-label="Select all members"
                checked={all}
                indeterminate={selected.length > 0 && !all}
                onCheckedChange={(checked) => setSelected(checked ? MEMBERS.map((member) => member.name) : [])}
              />
            </TableHead>
            <TableHead>Member</TableHead>
            <TableHead>Role</TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          {MEMBERS.map((member) => (
            <TableRow key={member.name} data-state={selected.includes(member.name) ? "selected" : undefined}>
              <TableCell>
                <Checkbox
                  aria-label={"Select " + member.name}
                  checked={selected.includes(member.name)}
                  onCheckedChange={(checked) =>
                    setSelected((current) => (checked ? [...current, member.name] : current.filter((name) => name !== member.name)))
                  }
                />
              </TableCell>
              <TableCell>{member.name}</TableCell>
              <TableCell>{member.role}</TableCell>
            </TableRow>
          ))}
        </TableBody>
      </Table>
    </div>
  )
}
```

### Density: compact rows or comfortable rows

```tsx
import { Badge } from "@/components/ui/badge"
import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from "@/components/ui/table"

const MEMBERS = [
  { name: "Nora Lindgren", role: "Owner", status: "Active" },
  { name: "Daniel Okafor", role: "Admin", status: "Active" },
  { name: "Priya Raman", role: "Member", status: "Active" },
  { name: "Tomás Ferreira", role: "Member", status: "Invited" },
] as const

export function Example() {
  return (
    <div className="overflow-hidden rounded-xl border border-border bg-card">
      <Table aria-label="Team members">
        <TableHeader>
          <TableRow>
            <TableHead>Member</TableHead>
            <TableHead>Role</TableHead>
            <TableHead>Status</TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          {MEMBERS.map((member) => (
            <TableRow key={member.name}>
              <TableCell>{member.name}</TableCell>
              <TableCell>{member.role}</TableCell>
              <TableCell>
                <Badge color={member.status === "Active" ? "green" : "yellow"} badgeStyle="light" shape="pill" size="sm">
                  {member.status}
                </Badge>
              </TableCell>
            </TableRow>
          ))}
        </TableBody>
      </Table>
    </div>
  )
}
```

### Width: fits, scrolls or wraps

```tsx
import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from "@/components/ui/table"

const INVOICES = [
  { id: "INV-2041", customer: "WunderUI", amount: "$24,800.00" },
  { id: "INV-2040", customer: "Halcyon Labs", amount: "$3,200.00" },
  { id: "INV-2039", customer: "Pergola Foods", amount: "$980.00" },
]

export function Example() {
  return (
    <div className="overflow-hidden rounded-xl border border-border bg-card">
      <Table aria-label="Recent invoices">
        <TableHeader>
          <TableRow>
            <TableHead>Invoice</TableHead>
            <TableHead>Customer</TableHead>
            <TableHead className="text-right">Amount</TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          {INVOICES.map((invoice) => (
            <TableRow key={invoice.id}>
              <TableCell>{invoice.id}</TableCell>
              <TableCell>{invoice.customer}</TableCell>
              <TableCell className="text-right tabular-nums">{invoice.amount}</TableCell>
            </TableRow>
          ))}
        </TableBody>
      </Table>
    </div>
  )
}
```

### States: ready, loading, empty and error

```tsx
import {
  Table,
  TableBody,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from "@/components/ui/table"

const INVOICES = [
  { id: "INV-2041", customer: "WunderUI", amount: "$24,800.00" },
  { id: "INV-2040", customer: "Halcyon Labs", amount: "$3,200.00" },
  { id: "INV-2039", customer: "Pergola Foods", amount: "$980.00" },
]

export function Example() {
  return (
    <div className="overflow-hidden rounded-xl border border-border bg-card">
      <Table aria-label="Recent invoices">
        <TableHeader>
          <TableRow>
            <TableHead>Invoice</TableHead>
            <TableHead>Customer</TableHead>
            <TableHead className="text-right">Amount</TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          {INVOICES.map((invoice) => (
            <TableRow key={invoice.id}>
              <TableCell>{invoice.id}</TableCell>
              <TableCell>{invoice.customer}</TableCell>
              <TableCell className="text-right tabular-nums">{invoice.amount}</TableCell>
            </TableRow>
          ))}
        </TableBody>
      </Table>
    </div>
  )
}
```

## In context

### Billing history: a settings page with a pager

The page heading names the table, so the caption is hidden. The footer holds the range and the pager, and a page of four rows keeps the height of the card.

```tsx
import { useState } from "react"
import { Badge } from "@/components/ui/badge"
import { Pagination, PaginationSummary } from "@/components/ui/pagination"
import { Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"

const STATUS = { Paid: "green", Open: "blue", Overdue: "red" } as const
const STATUSES = ["Paid", "Paid", "Paid", "Open", "Paid", "Overdue"] as const
const CUSTOMERS = ["WunderUI", "Halcyon Labs", "Pergola Foods", "Marlow & Finch", "Northbeam Studio", "Brightline"]
const PAGE_SIZE = 4

const usd = (value: number) => value.toLocaleString("en-US", { style: "currency", currency: "USD" })

// 48 invoices, newest first.
const INVOICES = Array.from({ length: 48 }, (_, i) => ({
  id: "INV-" + (2041 - i),
  status: STATUSES[i % STATUSES.length],
  customer: CUSTOMERS[i % CUSTOMERS.length],
  amount: 980 + ((i * 7919) % 24000),
}))

export function Example() {
  const [page, setPage] = useState(1)
  const pageCount = Math.ceil(INVOICES.length / PAGE_SIZE)
  const rows = INVOICES.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE)

  return (
    <section className="flex flex-col gap-4">
      <div>
        <h2 className="text-lg font-semibold text-foreground">Billing</h2>
        <p className="text-sm text-text-secondary">Invoices for your workspace, newest first.</p>
      </div>
      <div className="overflow-hidden rounded-xl border border-border bg-card">
        <Table>
          {/* The heading above names the table, so the caption is only for screen readers. */}
          <TableCaption className="sr-only">Invoices for your workspace, newest first</TableCaption>
          <TableHeader>
            <TableRow>
              <TableHead>Invoice</TableHead>
              <TableHead>Status</TableHead>
              <TableHead>Customer</TableHead>
              <TableHead className="text-right">Amount</TableHead>
            </TableRow>
          </TableHeader>
          <TableBody>
            {rows.map((invoice) => (
              <TableRow key={invoice.id}>
                <TableCell>{invoice.id}</TableCell>
                <TableCell>
                  <Badge color={STATUS[invoice.status]} badgeStyle="light" shape="pill" size="sm">
                    {invoice.status}
                  </Badge>
                </TableCell>
                <TableCell>{invoice.customer}</TableCell>
                <TableCell className="text-right tabular-nums">{usd(invoice.amount)}</TableCell>
              </TableRow>
            ))}
          </TableBody>
        </Table>
        {/* 8 px of air around the 8 px buttons inside the 16 px corners keeps them concentric. */}
        <div className="flex flex-wrap items-center justify-between gap-x-6 gap-y-2 border-t border-border p-2">
          <div className="px-2">
            <PaginationSummary page={page} pageSize={PAGE_SIZE} total={INVOICES.length} noun="invoice" />
          </div>
          <Pagination page={page} pageCount={pageCount} onPageChange={setPage} />
        </div>
      </div>
    </section>
  )
}
```

### Team members: people, roles and row actions

A person cell with an avatar, a role, a status badge and two icon actions. Remove takes the row out of the table.

```tsx
import { useState } from "react"
import { Pencil, Trash2 } from "lucide-react"
import { Badge } from "@/components/ui/badge"
import { ActionIconsCell, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, UserCell } from "@/components/ui/table"

const INITIAL_MEMBERS = [
  { name: "Nora Lindgren", initials: "NL", email: "info@wunderui.com", role: "Owner", status: "Active" },
  { name: "Daniel Okafor", initials: "DO", role: "Admin", status: "Active" },
  { name: "Priya Raman", initials: "PR", role: "Member", status: "Active" },
  { name: "Tomás Ferreira", initials: "TF", role: "Member", status: "Invited" },
]

export function Example() {
  const [members, setMembers] = useState(INITIAL_MEMBERS)

  return (
    <div className="overflow-hidden rounded-xl border border-border bg-card">
      <Table aria-label="Team members">
        <TableHeader>
          <TableRow>
            <TableHead>Member</TableHead>
            <TableHead>Role</TableHead>
            <TableHead>Status</TableHead>
            <TableHead>
              <span className="sr-only">Actions</span>
            </TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          {members.map((member) => (
            <TableRow key={member.name}>
              <TableCell>
                <UserCell name={member.name} initials={member.initials} email={member.email} avatarSize="default" />
              </TableCell>
              <TableCell>{member.role}</TableCell>
              <TableCell>
                <Badge color={member.status === "Active" ? "green" : "yellow"} badgeStyle="light" shape="pill" size="sm">
                  {member.status}
                </Badge>
              </TableCell>
              <TableCell>
                <ActionIconsCell
                  actions={[
                    { icon: <Pencil strokeWidth={1.5} />, label: "Edit " + member.name },
                    {
                      icon: <Trash2 strokeWidth={1.5} />,
                      label: "Remove " + member.name,
                      onClick: () => setMembers((current) => current.filter((item) => item.name !== member.name)),
                    },
                  ]}
                />
              </TableCell>
            </TableRow>
          ))}
        </TableBody>
      </Table>
      {members.length === 0 && <p className="border-t border-border p-6 text-center text-sm text-text-secondary">No members left.</p>}
    </div>
  )
}
```

### Usage this month: a named total

A table that ends in a summary row. The label says what the total is, and the figures stay right-aligned with their columns.

```tsx
import { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow } from "@/components/ui/table"

const USAGE = [
  { product: "Search API", requests: 482300, cost: 964.6 },
  { product: "Exports", requests: 311950, cost: 623.9 },
  { product: "Webhooks", requests: 128400, cost: 257 },
]

const usd = (value: number) => value.toLocaleString("en-US", { style: "currency", currency: "USD" })

export function Example() {
  const requests = USAGE.reduce((sum, row) => sum + row.requests, 0)
  const cost = USAGE.reduce((sum, row) => sum + row.cost, 0)

  return (
    <section className="flex flex-col gap-4">
      <div>
        <h2 className="text-lg font-semibold text-foreground">Usage this month</h2>
        <p className="text-sm text-text-secondary">Requests and cost per product, with the total.</p>
      </div>
      <div className="overflow-hidden rounded-xl border border-border bg-card">
        <Table>
          <TableCaption className="sr-only">Requests and cost per product this month</TableCaption>
          <TableHeader>
            <TableRow>
              <TableHead>Product</TableHead>
              <TableHead className="text-right">Requests</TableHead>
              <TableHead className="text-right">Cost</TableHead>
            </TableRow>
          </TableHeader>
          <TableBody>
            {USAGE.map((row) => (
              <TableRow key={row.product}>
                <TableCell>{row.product}</TableCell>
                <TableCell className="text-right tabular-nums">{row.requests.toLocaleString("en-US")}</TableCell>
                <TableCell className="text-right tabular-nums">{usd(row.cost)}</TableCell>
              </TableRow>
            ))}
          </TableBody>
          <TableFooter>
            <TableRow>
              <TableCell>Total</TableCell>
              <TableCell className="text-right tabular-nums text-foreground">{requests.toLocaleString("en-US")}</TableCell>
              <TableCell className="text-right tabular-nums text-foreground">{usd(cost)}</TableCell>
            </TableRow>
          </TableFooter>
        </Table>
      </div>
    </section>
  )
}
```

### Side card: a compact table

The same table in a narrower container. The text column wraps, the number column keeps its width, and nothing is cut off.

```tsx
import { Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"

const INVOICES = [
  { id: "INV-2041", customer: "WunderUI Design Systems and Brand Team", amount: "$24,800.00" },
  { id: "INV-2040", customer: "Halcyon Labs Europe", amount: "$3,200.00" },
  { id: "INV-2039", customer: "Pergola Foods", amount: "$980.00" },
  { id: "INV-2038", customer: "Marlow & Finch", amount: "$12,400.00" },
]

export function Example() {
  return (
    <aside className="w-full max-w-sm overflow-hidden rounded-xl border border-border bg-card">
      <Table className="caption-top">
        <TableCaption className="mt-0 px-4 py-3 text-left">
          <span className="block text-sm font-medium text-foreground">Recent invoices</span>
          <span className="block text-xs text-text-tertiary">A compact list next to the main content</span>
        </TableCaption>
        <TableHeader>
          <TableRow>
            <TableHead>Invoice</TableHead>
            <TableHead>Customer</TableHead>
            <TableHead className="text-right">Amount</TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          {INVOICES.map((invoice) => (
            <TableRow key={invoice.id}>
              <TableCell>{invoice.id}</TableCell>
              {/* A text column wraps; the number column keeps its width. */}
              <TableCell className="whitespace-normal">{invoice.customer}</TableCell>
              <TableCell className="text-right tabular-nums">{invoice.amount}</TableCell>
            </TableRow>
          ))}
        </TableBody>
      </Table>
    </aside>
  )
}
```

### Projects: dates, progress and missing values

Date, progress, percentage and a missing value in one table. A missing value is an em dash, never 0.

```tsx
import { ProgressCell } from "@/components/ui/progress"
import { Table, TableBody, TableCaption, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"

const PROJECTS = [
  { name: "Website relaunch", updated: "Sep 18, 2026", progress: 70, share: "48.2%" },
  { name: "Mobile app", updated: "Sep 12, 2026", progress: 48, share: "31.6%" },
  { name: "Docs migration", updated: "Aug 30, 2026", progress: 100, share: "12.4%" },
  { name: "Partner portal", updated: null, progress: null, share: null },
]

// A missing value is an em dash, never 0. Screen readers get the words.
function Missing() {
  return (
    <>
      <span aria-hidden>—</span>
      <span className="sr-only">No value</span>
    </>
  )
}

export function Example() {
  return (
    <div className="overflow-hidden rounded-xl border border-border bg-card">
      <Table>
        <TableCaption className="sr-only">Projects with their last update, progress and share</TableCaption>
        <TableHeader>
          <TableRow>
            <TableHead>Project</TableHead>
            <TableHead>Updated</TableHead>
            <TableHead>Progress</TableHead>
            <TableHead className="text-right">Share</TableHead>
          </TableRow>
        </TableHeader>
        <TableBody>
          {PROJECTS.map((project) => (
            <TableRow key={project.name}>
              <TableCell>{project.name}</TableCell>
              <TableCell>{project.updated ?? <Missing />}</TableCell>
              <TableCell>{project.progress === null ? <Missing /> : <ProgressCell value={project.progress} />}</TableCell>
              <TableCell className="text-right tabular-nums">{project.share ?? <Missing />}</TableCell>
            </TableRow>
          ))}
        </TableBody>
      </Table>
    </div>
  )
}
```

## For AI agents

`get_component("table")`

Hand your agent this page as Markdown or the WunderUI MCP server, not a screenshot.
