Skip to content
Esc
↑↓navigate↵open⌘Jpreview
On this page

Table for Astro

Semantic Astro table parts for records and comparisons.

Sample charges for completed studio visits.
InvoiceStatusMethodAmount
INV-001PaidCredit Card$250.00
INV-002PendingPayPal$150.00
INV-003UnpaidBank Transfer$350.00
Total$750.00

Installation

bunx --bun shadcn@latest add @gnostic/table

Usage

import {
    Table,
    TableBody,
    TableCaption,
    TableCell,
    TableFooter,
    TableHead,
    TableHeader,
    TableRow,
} from "@/components/ui/table"
<Table>
  <TableCaption>A list of your invoices.</TableCaption>
  <TableHeader>
    <TableRow>
      <TableHead>Invoice</TableHead>
      <TableHead>Status</TableHead>
      <TableHead>Amount</TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    <TableRow>
      <TableCell>INV-001</TableCell>
      <TableCell>Paid</TableCell>
      <TableCell>$250.00</TableCell>
    </TableRow>
  </TableBody>
</Table>

Composition

Arrange the parts as shown for a Table:

Table
├── TableCaption
├── TableHeader
│   └── TableRow
│       ├── TableHead
│       ├── TableHead
│       └── TableHead
├── TableBody
│   └── TableRow
│       ├── TableCell
│       ├── TableCell
│       └── TableCell
└── TableFooter

Notes

  • Keep table structure semantic: headers in TableHeader, rows in TableBody, and summary data in TableFooter when needed.
  • Right-align numeric columns so values are easier to scan.
  • Wrap large tables in a container with horizontal overflow when the content may exceed the available width.

Sizes and states

Content ready for handoff
PageReview
ServicesApproved
ContactSelected for review

API Reference

Read the installed source for the complete prop types.

When to use Table

Compose TableHeader, TableBody, rows, and cells from your data. Use header cells for column or row names and a caption when it helps identify the data. The wrapper allows horizontal overflow.

Keyboard and behavior

Native table markup preserves the relationship between headers and cells. The component does not add sorting, filtering, row selection, or pagination. Implement those as labelled controls and keep their state clear.

Theme and layout

Use variant="card" for the card table treatment or the default for a page table. Check long cells and narrow-screen overflow. Avoid hiding essential columns only to fit a small screen.