Skip to main content

table

A responsive table component.

Philosophy

HTML tables are semantically powerful but visually bland. Our Table components add consistent styling while preserving the native table structure - <table>, <thead>, <tbody>, <tr>, <th>, <td> - because screen readers depend on these elements for data navigation. For interactive features like sorting and filtering, see Data Table.

How It's Built

Loading diagram...

Installation


npx @gentleduck/cli add table

npx @gentleduck/cli add table

Usage

import {
  Table,
  TableBody,
  TableCaption,
  TableCell,
  TableHead,
  TableHeader,
  TableRow,
} from "@/components/ui/table"
<Table>
  <TableCaption>A list of your recent invoices.</TableCaption>
  <TableHeader>
    <TableRow>
      <TableHead className="w-[100px]">Invoice</TableHead>
      <TableHead>Status</TableHead>
      <TableHead>Method</TableHead>
      <TableHead className="text-right">Amount</TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    <TableRow>
      <TableCell className="font-medium">INV001</TableCell>
      <TableCell>Paid</TableCell>
      <TableCell>Credit Card</TableCell>
      <TableCell className="text-right">$250.00</TableCell>
    </TableRow>
  </TableBody>
</Table>

Examples

Data Table

You can use the <Table /> component to build more complex data tables. Combine it with TanStack Table to add sorting, filtering, and pagination.

See the Data Table documentation for a full guide.

You can also see data-table examples in the Blocks Library.

Component Composition

Loading diagram...

RTL Support

Set the direction once with DirectionProvider (or <html dir="rtl">) and the table follows it: cells align to the start side. No dir prop or rtl: classes needed.

Motion

Use MotionTable and MotionTableRow for staggered entrance animations powered by motion. The table uses a scaleIn entrance (fade, scale, and blur) with a bouncy spring transition, and each row staggers by 50ms via the index prop.

API Reference

Table

PropTypeDefaultDescription
dir'ltr' | 'rtl'-Text direction override. Resolved via useDirection (dir prop -> DirectionProvider -> <html dir>).
classNamestring-Additional CSS class names
childrenReact.ReactNode-Table content (TableHeader, TableBody, TableFooter, TableCaption)
...propsReact.HTMLProps<HTMLTableElement>-Additional props to spread to the table element

TableHeader

PropTypeDefaultDescription
classNamestring-Additional CSS class names
childrenReact.ReactNode-Header rows
...propsReact.HTMLProps<HTMLTableSectionElement>-Additional props to spread to the thead element

TableBody

PropTypeDefaultDescription
classNamestring-Additional CSS class names
childrenReact.ReactNode-Body rows
...propsReact.HTMLProps<HTMLTableSectionElement>-Additional props to spread to the tbody element

TableFooter

PropTypeDefaultDescription
classNamestring-Additional CSS class names
childrenReact.ReactNode-Footer rows
...propsReact.HTMLProps<HTMLTableSectionElement>-Additional props to spread to the tfoot element

TableRow

PropTypeDefaultDescription
classNamestring-Additional CSS class names
childrenReact.ReactNode-Row cells (TableHead or TableCell)
...propsReact.HTMLProps<HTMLTableRowElement>-Additional props to spread to the tr element

TableHead

PropTypeDefaultDescription
scopestring'col'HTML scope attribute for accessibility
classNamestring-Additional CSS class names
childrenReact.ReactNode-Header cell content
...propsReact.ThHTMLAttributes<HTMLTableCellElement>-Additional props to spread to the th element

TableCell

PropTypeDefaultDescription
classNamestring-Additional CSS class names
childrenReact.ReactNode-Cell content
...propsReact.TdHTMLAttributes<HTMLTableCellElement>-Additional props to spread to the td element

TableCaption

PropTypeDefaultDescription
classNamestring-Additional CSS class names
childrenReact.ReactNode-Caption text
...propsReact.HTMLProps<HTMLTableCaptionElement>-Additional props to spread to the caption element

MotionTable

scaleIn entrance (fade, scale, and blur) with springBouncy transition on mount. Requires the motion package.

PropTypeDefaultDescription
...propsTableProps-All props from Table are supported

MotionTableRow

Staggered scaleIn entrance (fade, scale, and blur) with springBouncy transition. Requires the motion package.

PropTypeDefaultDescription
indexnumber0Stagger delay index (50ms per index) for entrance animation
...propsTableRowProps-All props from TableRow are supported