Table
Sortable, selectable table with a sticky header and a row hover beam.
Built on Icons.
Deployments
1 of 7 selected
Cache edge config between deploysmain · 8f3a2c1 | Building | — | just now | |
Redesign the billing settings pagefeat/billing-v2 · 3b8e51f | Queued | — | 1m ago | |
Fix flaky checkout testmain · a1f9c2e | Ready | 1m 12s | 14m ago | |
Add OTP input to sign-infeat/otp-input · 7c3d10b | Ready | 1m 35s | 38m ago | |
Bump next to 16.4.0deps/next-16-4 · c93e4a8 | Error | 41s | 1h ago | |
Tighten rate limits on searchfix/search-limits · 5d2f61b | Ready | 1m 06s | 2h ago | |
Translate onboarding into Germani18n/de · e0b7a93 | Canceled | 12s | 3h ago |
Installation
npx shadcn@latest add https://neonkit.heyaadi.com/r/table.jsonUsage
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table"
<Table aria-label="Deployments">
<TableHeader>
<TableRow>
<TableHead sortDirection="desc" onSort={toggleSort}>Created</TableHead>
<TableHead align="right">Duration</TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow selected>
<TableCell>4m ago</TableCell>
<TableCell align="right">1m 12s</TableCell>
</TableRow>
</TableBody>
</Table>Examples
Data table
Sorting, selection with Checkbox and Pagination wired together. Selection survives paging and sorting; the header checkbox covers the current page.
Sticky header in a Scroll Area
The header pins to the nearest scroll container. Here the ScrollArea scrolls, so the table's own container is set to overflow-visible and edge fades are off to keep the header crisp.
Compact, with footer and caption
API reference
Table
Renders a <table> inside a framed container that scrolls sideways when the table is too wide. Native table attributes, className and ref go to the <table>.
| Prop | Type | Default |
|---|---|---|
density | "compact"Row height and cell padding. | "normal" |
stickyHeader | booleanPins the header row to the top of the nearest scroll container. Give the container a max-height, or make it overflow-visible inside an outer scroller. | false |
containerClassName | stringClasses for the container, e.g. max-h-96, or border-0 to drop the frame. | None |
color | NeonColorSelection tint, lit edge, beam and sort arrow. Falls back to --neon-accent, then cyan. | inherited |
TableHead
A <th>. scope is col in the header and row elsewhere.
| Prop | Type | Default |
|---|---|---|
onSort | () => voidRenders the label as a sort button. Work out the next direction in your handler. | None |
sortDirection | "asc"Sets aria-sort and points the arrow. Unsorted columns show the arrow on hover. | false |
align | "left"Right-aligned sortable heads put the arrow before the label so numbers line up. | "left" |
TableRow
A <tr>. Body rows light up on hover; header and footer rows don't.
| Prop | Type | Default |
|---|---|---|
selected | booleanNeon tint and a lit left edge. Also sets aria-selected. | None |
interactive | booleanPointer cursor and a pressed state for rows that respond to clicks. | false |
TableCell
A <td>.
| Prop | Type | Default |
|---|---|---|
align | "left"Text alignment. Numbers use tabular figures throughout the table. | "left" |
TableHeader, TableBody, TableFooter, TableCaption
<thead>, <tbody>, <tfoot> and <caption>, with native attributes. The caption sits under the table.
| Prop | Type | Default |
|---|---|---|
className | stringExtra classes. | None |
Accessibility
- It's a real HTML table, so screen readers announce rows, columns and headers. Name it with aria-label or a TableCaption.
- Sortable headers are buttons inside the <th>; the sorted column gets aria-sort, so the direction is announced with the header.
- Row selection belongs on a real control: put a Checkbox with an aria-label in the row. Clicking the row itself is a pointer shortcut, not the only way.
- interactive only styles the row. If a row navigates, put a link in its primary cell so keyboard users can reach it.
- The hover beam is transform-only and is skipped with reduced motion.