# Data table: Plain table

> The plain `<Table />` parts the data table is built from. Use them on their own for static data, with a caption and a footer total.

Example: https://hextaui.com/docs/data-table/examples/table
Component docs: https://hextaui.com/docs/data-table.md

## Add this example

```bash
npx shadcn@latest add https://hextaui.com/r/data-table-table.json
```

This adds `components/examples/data-table/table.tsx` with the Data table component and the HextaUI theme tokens.

## Source

```tsx title="components/examples/data-table/table.tsx"
import {
  Table,
  TableBody,
  TableCaption,
  TableCell,
  TableFooter,
  TableHead,
  TableHeader,
  TableRow,
} from "@/components/ui/table"

const invoices = [
  { id: "INV001", status: "Paid", method: "Credit card", amount: 250 },
  { id: "INV002", status: "Pending", method: "PayPal", amount: 150 },
  { id: "INV003", status: "Unpaid", method: "Bank transfer", amount: 350 },
  { id: "INV004", status: "Paid", method: "Credit card", amount: 450 },
]

const currency = new Intl.NumberFormat("en-US", {
  style: "currency",
  currency: "USD",
})

export function TableDemo() {
  const total = invoices.reduce((sum, invoice) => sum + invoice.amount, 0)

  return (
    <Table>
      <TableCaption>A list of your recent invoices.</TableCaption>
      <TableHeader>
        <TableRow>
          <TableHead>Invoice</TableHead>
          <TableHead>Status</TableHead>
          <TableHead>Method</TableHead>
          <TableHead align="end">Amount</TableHead>
        </TableRow>
      </TableHeader>
      <TableBody>
        {invoices.map((invoice) => (
          <TableRow key={invoice.id}>
            <TableCell>{invoice.id}</TableCell>
            <TableCell>{invoice.status}</TableCell>
            <TableCell>{invoice.method}</TableCell>
            <TableCell align="end">{currency.format(invoice.amount)}</TableCell>
          </TableRow>
        ))}
      </TableBody>
      <TableFooter>
        <TableRow>
          <TableCell colSpan={3}>Total</TableCell>
          <TableCell align="end">{currency.format(total)}</TableCell>
        </TableRow>
      </TableFooter>
    </Table>
  )
}
```

## More Data table examples

- [Loading](https://hextaui.com/docs/data-table/examples/loading.md)
- [Empty](https://hextaui.com/docs/data-table/examples/empty.md)
- [Sticky header](https://hextaui.com/docs/data-table/examples/sticky-header.md)
- [Pinned columns](https://hextaui.com/docs/data-table/examples/pinned-columns.md)
- [Right to left](https://hextaui.com/docs/data-table/examples/rtl.md)
