A responsive table for tabular data.
$ pnpm dlx shadcn@latest add https://dashral.com/r/table.jsonInstallation
$ pnpm dlx shadcn@latest add https://dashral.com/r/table.jsonAdds the component, the components it builds on, its npm packages and the theme tokens it uses. Using Dashral often? Add the registry to components.json once:
components.json
{
"registries": {
"@dashral": "https://dashral.com/r/{name}.json"
}
}Then add components by name:
$ pnpm dlx shadcn@latest add @dashral/tableUsage
example.tsx
import { Table, TableHeader, TableBody, TableHead, TableRow, TableCell, TableCaption } from "@/components/dashral/table"
<Table>
<TableCaption>Recent invoices</TableCaption>
<TableHeader>
<TableRow>
<TableHead>Invoice</TableHead>
<TableHead className="text-right">Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{invoices.map((invoice) => (
<TableRow key={invoice.id}>
<TableCell>{invoice.id}</TableCell>
<TableCell className="text-right tabular-nums">{invoice.amount}</TableCell>
</TableRow>
))}
</TableBody>
</Table>Examples
Recent orders
Avatars, status badges and a menu of actions on each row; the row lights up under the pointer.
| Order | Customer | Product | Status | Date | Amount | Actions |
|---|---|---|---|---|---|---|
| #1042 | Olivia Martinolivia@acme.com | Retro 35mm Film Camera | Paid | Oct 16 | $159.00 | |
| #1041 | Liam Johnsonliam@acme.com | Pour-over Coffee Set | Shipped | Oct 15 | $64.50 | |
| #1040 | Budi Santosobudi@nusantara.id | Mechanical Keyboard | Processing | Oct 15 | $219.00 | |
| #1039 | Sofia Davissofia@acme.com | Linen Desk Mat | Refunded | Oct 14 | $39.00 |
Bulk actions
Tick rows (or click them) and a bar with actions for the selection appears; archiving can be undone.
API reference
Table, TableHeader, TableBody, TableFooter, TableRow, TableHead, TableCell, TableCaption
Styled table elements; the table scrolls sideways when it doesn't fit.
Also takes every prop of <table>(opens in a new tab).
Accessibility
- Real table semantics: use TableHead for headers and a TableCaption (visually hidden is fine) to name the table.