Back to Tooljet

Table — Rocket Design Spec

frontend/src/components/ui/Rocket/Table/Table.spec.md

3.20.154-lts4.6 KB
Original Source

Table — Rocket Design Spec

<!-- synced: 2026-04-07 -->

Overview

Table is the low-level Rocket primitive for tabular data. Wraps shadcn's <table> primitive with ToolJet token overrides. Used as the structural base for higher-level compositions like DataTable (TanStack-driven) and feature tables (apps list, datasources list, workflows list, etc.).

The HOC layer only handles structure + visual tokens. State (sorting, filtering, pagination, selection) is the responsibility of the consumer or the DataTable block.

Brought forward from PR #14498 with improved organization and ToolJet token usage.

Props

Table (root)

PropTypeValuesDefault
densitystringdefault | compactdefault
classNamestring

TableRow

PropTypeValuesDefault
data-statestring"selected" | undefined
classNamestring

Density (Sizes)

ValueHeader heightHeader paddingCell heightCell paddingFont
default40px0 / 14px52px14pxtw-text-base (12px)
compact32px0 / 12px36px8px / 12pxtw-text-base (12px)

Density is set via context on Table and read by TableHead / TableCell.

Sub-components

ComponentElementToken overrides
Table<table> inside scrollable <div>bg, w-full, font tokens
TableHeader<thead>border-bottom on rows
TableBody<tbody>last row no border
TableFooter<tfoot>border-top, surface bg, medium font
TableRow<tr>border-bottom, hover bg, selected bg
TableHead<th>header height (density), title font, text-default, left-align
TableCell<td>cell padding (density), body font, text-default
TableCaption<caption>mt-4, body small, text-placeholder

Token Mapping

ElementStateToolJet class
Table containerdefaulttw-relative tw-w-full tw-overflow-auto
Tabledefaulttw-w-full tw-caption-bottom tw-border-separate tw-border-spacing-0 tw-font-body-default tw-text-text-default
TableHeaderdefaulttw-border-solid tw-border-0 tw-border-b tw-border-border-weak
TableRowdefaulttw-transition-colors
TableRowhoverhover:tw-bg-interactive-hover
TableRowselecteddata-[state=selected]:tw-bg-interactive-selected
TableHeaddefaulttw-h-10 tw-px-3.5 tw-py-0 tw-text-left tw-align-middle tw-font-title-default tw-text-text-default
TableHeadcompacttw-h-8 tw-px-3 tw-py-0
TableCelldefaulttw-h-[52px] tw-p-3.5 tw-align-middle tw-text-text-default first:tw-rounded-l-[10px] last:tw-rounded-r-[10px]
TableCellcompacttw-h-9 tw-px-3 tw-py-2 first:tw-rounded-l-[10px] last:tw-rounded-r-[10px]
TableFooterdefaulttw-border-solid tw-border-0 tw-border-t tw-border-border-weak tw-bg-background-surface-layer-02 tw-font-title-default
TableCaptiondefaulttw-mt-4 tw-font-body-small tw-text-text-placeholder

CVA Shape

Shape C — sizes only (density). Plus a TableDensityContext so child components (TableHead, TableCell) read density from the root Table.

Slots

Standard HTML table slots — consumer composes via sub-components.

Notes

  • Wraps the shadcn table primitive (installed at Rocket/shadcn/table.jsx).
  • Replaces all shadcn semantic classes (tw-bg-muted, tw-text-foreground) with ToolJet tokens via className override.
  • density prop controls row/cell heights via context — font stays 12px Medium (tw-font-title-default) on header and 12px Regular (tw-font-body-default) on body across both densities.
  • Borderless rows — rows do NOT have bottom borders. Visual separation comes from the hover/selected background which uses rounded-[10px] corners on the first/last cells, creating a "pill" highlight.
  • The <table> itself uses tw-border-separate tw-border-spacing-0 so the rounded cell corners render correctly (the default border-collapse collapses cell borders and breaks the rounded corners).
  • Header has a single border-bottom (tw-border-border-weak) on TableHeader — separates header from body.
  • Hover and selected states use tw-bg-interactive-hover and tw-bg-interactive-selected.
  • TableFooter uses surface-layer-02 bg + medium font weight (slightly emphasized).
  • Higher-level features (sorting indicators, sticky header, loading skeleton, empty state, pagination) live in the DataTable block (layer 2), not here.
  • Typography uses tw-font-* plugin utilities — never manual font combos.