A responsive table with a surface style, wrapping or compact cells, sticky headers, pinned columns and scroll hints.
Install
Add it to your project
Run this in a project set up for shadcn/ui. It writes the files and installs the npm packages.
First time: connect the Infinity UI registry
- Create a personal token on your Tokens page.
- Put it in
.env.localasINFINITYUI_TOKEN. - Add the registry to
components.json:
{
"registries": {
"@infinityui": {
"url": "https://infinityui.io/r/{name}.json",
"headers": {
"Authorization": "Bearer ${INFINITYUI_TOKEN}"
}
}
}
}Using Claude Code, Codex, Cursor, Lovable or v0? See CLI & MCP for a setup prompt.
npm packages it adds
- cn
- class-variance-authority
Code
import { Badge, BadgeDot } from "@/components/ui/badge"
import {
Table,
TableBody,
TableCell,
TableFooter,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table"
const invoices = [
{ id: "INV-0418", client: "Northwind", status: "Paid", amount: 2400 },
{ id: "INV-0419", client: "Globex", status: "Pending", amount: 860 },
{ id: "INV-0420", client: "Initech", status: "Paid", amount: 1320.5 },
{ id: "INV-0421", client: "Umbrella", status: "Overdue", amount: 415 },
]
const currency = new Intl.NumberFormat("en-US", {
style: "currency",
currency: "USD",
})
const tones = {
Paid: "success",
Pending: "info",
Overdue: "destructive",
} as const
export function TableDemo() {
const total = invoices.reduce((sum, invoice) => sum + invoice.amount, 0)
return (
<Table variant="surface" className="min-w-md">
<TableHeader>
<TableRow>
<TableHead>Invoice</TableHead>
<TableHead>Client</TableHead>
<TableHead>Status</TableHead>
<TableHead align="end">Amount</TableHead>
</TableRow>
</TableHeader>
<TableBody>
{invoices.map((invoice) => (
<TableRow key={invoice.id}>
<TableHead scope="row">{invoice.id}</TableHead>
<TableCell>{invoice.client}</TableCell>
<TableCell>
<Badge variant={tones[invoice.status as keyof typeof tones]}>
<BadgeDot />
{invoice.status}
</Badge>
</TableCell>
<TableCell align="end">{currency.format(invoice.amount)}</TableCell>
</TableRow>
))}
</TableBody>
<TableFooter>
<TableRow>
<TableCell colSpan={3}>Total</TableCell>
<TableCell align="end">{currency.format(total)}</TableCell>
</TableRow>
</TableFooter>
</Table>
)
}
































