Table
A responsive table component.
| Invoice | Status | Method | Amount |
|---|---|---|---|
| INV001 | Paid | Credit card | $250.00 |
| INV002 | Pending | PayPal | $150.00 |
| INV003 | Unpaid | Bank transfer | $350.00 |
| INV004 | Paid | Credit card | $450.00 |
| INV005 | Paid | PayPal | $550.00 |
| Total | $1,750.00 | ||
Installation
npx shadcn@latest add @uqudo/tableUsage
import {
Table,
TableBody,
TableCaption,
TableCell,
TableFooter,
TableHead,
TableHeader,
TableRow,
} from "@/components/uqudo/ui/table"<Table>
<TableCaption>A list of your recent invoices.</TableCaption>
<TableHeader>
<TableRow>
<TableHead>Invoice</TableHead>
<TableHead>Status</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow>
<TableCell>INV001</TableCell>
<TableCell>Paid</TableCell>
</TableRow>
</TableBody>
</Table>Each component is a thin wrapper around the matching HTML element, so anything
you know about <table> applies: colSpan, scope, align, event handlers
and so on pass straight through.
Table wraps the <table> in a div with data-slot="table-container" and
overflow-x-auto, so a wide table scrolls horizontally inside its parent
instead of breaking the page layout. Constrain the width of that parent, not the
table itself.
API Reference
Every component forwards className (merged through cn()) and all other props
of the element it renders.
| Component | Renders | Notes |
|---|---|---|
Table | <table> | Wrapped in a scrollable div with data-slot="table-container". |
TableHeader | <thead> | Adds a bottom border to its rows. |
TableBody | <tbody> | Removes the border of the last row. |
TableFooter | <tfoot> | Muted background, medium font weight, top border. |
TableRow | <tr> | Highlights on hover and when data-state="selected" is set. |
TableHead | <th> | Start-aligned, medium weight header cell. Trims end padding when it contains a checkbox. |
TableCell | <td> | Standard cell. Trims end padding when it contains a checkbox. |
TableCaption | <caption> | Rendered below the table in muted text. |
Table
Prop
Type
TableRow
Prop
Type
Data attributes
| Attribute | Value |
|---|---|
data-slot | table-container, table, table-header, table-body, table-footer, table-row, table-head, table-cell or table-caption. |