Table
Data DisplayHTML table primitives (Table, TableHeader, TableBody, TableRow, TableCell) with consistent styling.
Responsive viewport — resize the window to explore. Direction and density apply only to this preview. Theme applies to the docs too.
"use client";
import {
Table,
TableCaption,
TableHeader,
TableBody,
TableRow,
TableHead,
TableCell,
TableFooter,
} from "@dashboardpack/core/components/ui/table";
import { Badge } from "@dashboardpack/core/components/ui/badge";
export default function TableExample() {
return (
<Table>
<TableCaption>Recent workspace invoices.</TableCaption>
<TableHeader>
<TableRow>
<TableHead>Invoice</TableHead>
<TableHead>Status</TableHead>
<TableHead className="text-end">Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{[
{ id: "INV-001", status: "Paid", amount: "$240.00" },
{ id: "INV-002", status: "Pending", amount: "$120.00" },
].map((invoice) => (
<TableRow key={invoice.id}>
<TableCell className="font-medium">{invoice.id}</TableCell>
<TableCell>
<Badge
variant={invoice.status === "Paid" ? "success" : "warning"}
>
{invoice.status}
</Badge>
</TableCell>
<TableCell className="text-end">{invoice.amount}</TableCell>
</TableRow>
))}
</TableBody>
<TableFooter>
<TableRow>
<TableCell colSpan={2}>Total</TableCell>
<TableCell className="text-end">$360.00</TableCell>
</TableRow>
</TableFooter>
</Table>
);
}Usage
Compose semantic table elements for small static datasets. Use TableCaption for context and TableHead for column labels. Choose DataTable when you need filtering or pagination.
import {
Table,
TableCaption,
TableHeader,
TableBody,
TableRow,
TableHead,
TableCell,
TableFooter,
} from "@dashboardpack/core/components/ui/table";Available in the included @dashboardpack/core package. Copy the complete example from Source code for all imports and state. Add "use client" when using hooks or event handlers. See installation and theming for project setup.
API reference
Common props and defaults. Slot-specific props are named below; native elements also accept their standard HTML attributes. The component TypeScript definitions are the complete type reference.
| Prop | Type / Default | Description |
|---|---|---|
| children | ReactNodeDefault: — | Compose header, body, footer, and caption slots. |
| className | stringDefault: — | Extend styles on each slot. |
| colSpan (TableCell) | numberDefault: 1 | Number of columns spanned by a cell. |