shadcn.io is not affiliated with official shadcn/ui
| 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 |
| INV006 | Pending | Bank Transfer | $200.00 |
| INV007 | Unpaid | Credit Card | $300.00 |
| Total | $2,500.00 | ||
Installation
bunx --bun shadcn@latest add https://kit.dev/r/radix/table.jsonnpx shadcn@latest add https://kit.dev/r/radix/table.jsonpnpm dlx shadcn@latest add https://kit.dev/r/radix/table.jsonyarn shadcn@latest add https://kit.dev/r/radix/table.jsonCopy and paste the following code into your project.
"use client";
import type React from "react";
import { cn } from "@/lib/utils";
export const Table = (props: React.ComponentProps<"table">) => {
const { className, ...rest } = props;
return (
<div className="cn-table-container" data-slot="table-container">
<table
className={cn("cn-table", className)}
data-slot="table"
{...rest}
/>
</div>
);
};Update the import paths to match your project setup.
Usage
import {
Table,
TableBody,
TableCaption,
TableCell,
TableFooter,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table";const invoices = [
{
invoice: "INV001",
paymentMethod: "Credit Card",
paymentStatus: "Paid",
totalAmount: "$250.00",
},
{
invoice: "INV002",
paymentMethod: "PayPal",
paymentStatus: "Pending",
totalAmount: "$150.00",
},
{
invoice: "INV003",
paymentMethod: "Bank Transfer",
paymentStatus: "Unpaid",
totalAmount: "$350.00",
},
{
invoice: "INV004",
paymentMethod: "Credit Card",
paymentStatus: "Paid",
totalAmount: "$450.00",
},
{
invoice: "INV005",
paymentMethod: "PayPal",
paymentStatus: "Paid",
totalAmount: "$550.00",
},
{
invoice: "INV006",
paymentMethod: "Bank Transfer",
paymentStatus: "Pending",
totalAmount: "$200.00",
},
{
invoice: "INV007",
paymentMethod: "Credit Card",
paymentStatus: "Unpaid",
totalAmount: "$300.00",
},
];
const TableDemo = () => (
<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>
{invoices.map((invoice) => (
<TableRow key={invoice.invoice}>
<TableCell className="font-medium">{invoice.invoice}</TableCell>
<TableCell>{invoice.paymentStatus}</TableCell>
<TableCell>{invoice.paymentMethod}</TableCell>
<TableCell className="text-right">{invoice.totalAmount}</TableCell>
</TableRow>
))}
</TableBody>
<TableFooter>
<TableRow>
<TableCell colSpan={3}>Total</TableCell>
<TableCell className="text-right">$2,500.00</TableCell>
</TableRow>
</TableFooter>
</Table>
);
Demos
Footer
Use the TableFooter component to add a footer to the table.
Actions
A table showing actions for each row using a Menu component.
Rtl
Right-to-left table. See the RTL configuration guide for document direction.
API Reference
Table
PropType
AttributeType
TableHeader
PropType
AttributeType
TableBody
PropType
AttributeType
TableFooter
PropType
AttributeType
TableRow
PropType
AttributeType
TableHead
PropType
AttributeType
TableCell
PropType
AttributeType
TableCaption
PropType
AttributeType