shadcn.io is an independent project built on shadcn/ui
Each row has a checkbox, then Name, Category, Price and Stock. A select-all checkbox sits in the header, and Name is a button with a sort icon. Laptop is first, in Electronics.
Use row checkboxes when people act on a selection. A plain Table is enough when nothing is selected. On React, Ark UI does not track which rows are checked.
Installation
Usage
<div className="w-full max-w-4xl">
<div className="rounded-md border bg-background">
<Table>
<TableHeader>
{table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id}>
{headerGroup.headers.map((header) => (
<TableHead key={header.id}>
{header.isPlaceholder ? null : (
<table.FlexRender header={header} />
)}
</TableHead>
))}
</TableRow>
))}
</TableHeader>
<TableBody>
{rows.length > 0 ? (
rows.map((row) => (
<TableRow
data-state={row.getIsSelected() ? "selected" : undefined}
key={row.id}
>
{row.getAllCells().map((cell) => (
<TableCell key={cell.id}>
<table.FlexRender cell={cell} />
</TableCell>
))}
</TableRow>
))
) : (
{/* The rest of the file is under Installation. */}FAQ
When is the header checkbox indeterminate?
When some rows are selected but not all. checked is true, false or "indeterminate" from table.getIsAllPageRowsSelected() and table.getIsSomePageRowsSelected(), and onCheckedChange receives { checked }.
How does a row checkbox toggle?
checked is row.getIsSelected(), and onCheckedChange calls row.toggleSelected. The row checkbox is labeled Select row and the header's Select all.Does sorting clear the selection?
No. Selection and sorting are separate parts of the table's state, and the selection is keyed by row, so a sorted row keeps its check.
How do I read which rows are selected?
table.getSelectedRowModel().rows holds them; the line under the table prints its length against the five products. A selected TableRow gets data-state="selected", which shades it.
API Reference
Table
Sets data-state={row.getIsSelected() ? "selected" : undefined} and colSpan={columns.length}. The rest is on the Table page.





