Table
Powerful responsive data table with sticky headers, smooth scrolling, sorting, and pagination.
ID | Name | Age | Role | |
---|---|---|---|---|
1 | shadcn | shadcn@example.com | 26 | Pro Developer |
2 | Ahdeetai | ahdeetai@example.com | 21 | Cool Developer |
3 | ManuArora | manuarora@example.com | 35 | Ace Developer |
4 | DavidHaz | davidhaz@example.com | 27 | Top Developer |
5 | Roy | roy@example.com | 31 | Star Developer |
Total members | 5 |
Installation
npx shadcn@latest add https://scrollxui.dev/registry/table.json
Usage
// Basic Usage
import {
Table,
TableBody,
TableCaption,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table"
<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>
<TableRow>
<TableCell className="font-medium">INV001</TableCell>
<TableCell>Paid</TableCell>
<TableCell>Credit Card</TableCell>
<TableCell className="text-right">$250.00</TableCell>
</TableRow>
</TableBody>
</Table>
// DataTable Example
<DataTable
columns={[
{ accessorKey: 'invoice', header: createSortableHeader('Invoice') },
{ accessorKey: 'status', header: 'Status' },
{ accessorKey: 'method', header: 'Method' },
{ accessorKey: 'amount', header: 'Amount', cell: ({ row }) => `$${row.original.amount}` },
]}
data={[
{ invoice: 'INV001', status: 'Paid', method: 'Credit Card', amount: 250 },
{ invoice: 'INV002', status: 'Pending', method: 'PayPal', amount: 150 },
]}
pageSize={5}
searchable
pagination
/>
Examples
DataTable
1 | shadcn | shadcn@example.com | 26 | Pro Developer |
2 | Ahdeetai | ahdeetai@example.com | 21 | Cool Developer |
3 | ManuArora | manuarora@example.com | 35 | Ace Developer |
4 | DavidHaz | davidhaz@example.com | 27 | Top Developer |
5 | Roy | roy@example.com | 31 | Star Developer |
0 of 7 row(s) selected.
Rows per page:
Page 1 of 2
Scrollable
1 | shadcn | shadcn@example.com | 26 | Pro Developer |
2 | Ahdeetai | ahdeetai@example.com | 21 | Cool Developer |
3 | ManuArora | manuarora@example.com | 35 | Ace Developer |
4 | DavidHaz | davidhaz@example.com | 27 | Top Developer |
5 | Roy | roy@example.com | 31 | Star Developer |
6 | Lee Robinson | leerobinson@example.com | 38 | Master Developer |
7 | Guillermo Rauch | guillermorauch@example.com | 34 | Best Developer |
8 | Dan Abramov | danabramov@example.com | 28 | Prime Developer |
9 | Kent C. Dodds | kentcdodds@example.com | 30 | Epic Developer |
10 | Mark Zuckerberg | markzuckerberg@example.com | 41 | Boss Developer |
Checkbox
1 | shadcn | shadcn@example.com | 26 | Pro Developer | |
2 | Ahdeetai | ahdeetai@example.com | 21 | Cool Developer | |
3 | ManuArora | manuarora@example.com | 35 | Ace Developer | |
4 | DavidHaz | davidhaz@example.com | 27 | Top Developer | |
5 | Roy | roy@example.com | 31 | Star Developer |
0 of 7 row(s) selected.
Rows per page:
Page 1 of 2
API Reference
Table
Powerful responsive data table with sticky headers, smooth scrolling, sorting, and pagination.