Table
A responsive table with a surface style, wrapping or compact cells, sticky headers, pinned columns and scroll hints.
Used in Pro blocks: Billing
| Invoice | Client | Status | Amount |
|---|---|---|---|
| INV-0418 | Northwind | $2,400.00 | |
| INV-0419 | Globex | $860.00 | |
| INV-0420 | Initech | $1,320.50 | |
| INV-0421 | Umbrella | $415.00 | |
| Total | $4,995.50 | ||
pnpm dlx shadcn@latest add https://hextaui.com/r/table.jsonAdds the component, the HextaUI theme tokens and any HextaUI components it depends on.
Add the theme tokens to your global CSS, if you haven’t yet.
Install the dependencies.
pnpm add class-variance-authority cnCopy and paste the following code into your project.
components/ui/table.tsx Update the import paths to match your project setup.
Use <TableHead scope="row"> for the cell that names each row. It reads as the row's header to screen readers and gets a stronger text color. For sorting, filtering and selection, build on <DataTable />.
The default variant has no surface, just hairlines between rows, for tables that sit inside a card or a page section. <TableCaption /> describes the table below it.
size="sm" tightens row height and padding for dense data.
Cells stay on one line by default, which suits data. wrap lets them wrap and aligns rows to the top, for prose like glossaries or API references. Pair it with table-fixed and column widths.
Tables wider than their container scroll sideways. Soft fades show there's more on either side, and the scroll area becomes focusable so keyboard users can scroll it with the arrow keys. Turn the fades off with scrollFade={false}.
pinned="start" keeps the first column in view while the rest scrolls, and pinnedEdge shows a shadow once content slides under it.
stickyHeader keeps the header in view in a height-limited table, and adds a hairline under it once rows scroll beneath.
Alignment, pinned columns and scroll fades follow the reading direction.
| Key | Action |
|---|---|
| Tab | Focuses the scroll area when the table overflows, then the links and buttons inside it. |
| ←→ | Scrolls a focused, overflowing table sideways. |
| ↑↓ | Scrolls a focused table with a sticky header up and down. |
- The parts render native table elements, so screen readers announce rows, columns and headers without extra roles.
- Mark the cell that names a row with
<TableHead scope="row">so each value is read with its row and column. - The scroll area only joins the tab order while it overflows, so tables that fit don't add an extra stop.
Every part renders its native element and accepts its attributes.
| Prop | Type | Default |
|---|---|---|
variantsurface adds a rounded hairline frame and a muted header band. | "default" | "surface" | "default" |
size | "sm" | "default" | "default" |
wrapLet cell text wrap and align rows to the top. | boolean | false |
scrollFadeFade the edges that have more content to scroll to. Skipped when columns are pinned. | boolean | true |
stickyHeaderKeep the header in view. Give the container a max height through containerClassName. | boolean | false |
containerClassNameClasses for the scroll container. | string | – |
containerRefRef to the scroll container. | Ref<HTMLDivElement> | – |
| Attribute | Description |
|---|---|
data-slot="table-frame" | The outer frame, with data-variant, data-size and data-wrap. |
data-slot="table-container" | The scroll container. |
data-overflowing | Present on the container while its content overflows. It's focusable then. |
data-scrolled-start / data-scrolled-end | Present while there's content hidden before or after the visible area. |
data-scrolled-top | Present once a sticky-header table has scrolled. |
--table-bg | Row background. Follows a surrounding card or popover. |
--table-head-bg | Header band background in the surface variant. |
--table-cell-px / --table-cell-py | Cell padding. Set by size. |
| Prop | Type | Default |
|---|---|---|
scopeUse row for the cell that names a row. Inside the body it gets cell padding and foreground text. | "col" | "row" | – |
alignend also switches to tabular numbers so digits line up. | "start" | "center" | "end" | "start" |
pinnedKeep the column in view while the table scrolls sideways. Set the same value on its header and every cell. | "start" | "end" | – |
pinnedEdgeDraw a soft shadow on the inner edge of the last pinned column while content is hidden behind it. | boolean | false |
| Attribute | Description |
|---|---|
data-slot="table-head" | Target header cells in CSS. |
data-align | The alignment. |
data-pinned | The pinned side. |
| Prop | Type | Default |
|---|---|---|
alignend also switches to tabular numbers so digits line up. | "start" | "center" | "end" | "start" |
pinnedKeep the column in view while the table scrolls sideways. Set the same value on its header and every cell. | "start" | "end" | – |
pinnedEdgeDraw a soft shadow on the inner edge of the last pinned column while content is hidden behind it. | boolean | false |
| Attribute | Description |
|---|---|
data-slot="table-cell" | Target cells in CSS. |
data-align | The alignment. |
data-pinned | The pinned side. |
| Attribute | Description |
|---|---|
data-slot="table-row" | Target rows in CSS. |
data-state="selected" | Set it to highlight a selected row. |
| Attribute | Description |
|---|---|
data-slot="table-header" | The thead. |
data-slot="table-body" | The tbody. |
data-slot="table-footer" | The tfoot, on the header band color. |
data-slot="table-caption" | Below the table. In the surface variant it sits inside the frame. |
- AvatarUser photos with an initials fallback, status badges and stacked groups that collapse into a count.
- BadgeStatus labels with colored dots, removable tags that slide closed and counts that roll to their new value.
- CardA surface for grouping content, with three variants, edge-to-edge media, concentric radii and whole-card links.
- ChartRecharts charts with themed colors, a tooltip and legend that read labels from one config, and keyboard navigation with a visible focus ring.
- Data tableA table for real data, with sorting, search, row selection, pinned columns, a sticky header and pagination.
- ItemA row of media, text and actions for lists, settings and pickers, with a grouped surface and a hover highlight that glides between rows.
Used in Pro blocks
Blocks that build on Table.
Every block comes with HextaUI Pro, and Prompt Input is free.