Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Collections

  • QuestionCard
  • Table
  • Book3D
  • ProTable
  • PricingTable
  • JsonViewer
  • EditableTable
  • List
  • Descriptions
  • RowActions
  • Tree
  • Card
  • Carousel
  • Video
  • Audio
  • BentoGrid
  • Image
  • MagicCard
  • AnimatedList
  • Marquee
  • Sortable
  • Kanban
  • DesignCanvas
  • LayerTree
  • StageDraw
  • SlideDeck
  • PresenterView
  • ComponentPicker
  • EventStream
  • QueueLane
  • DocumentSheet
  • Novel reader
  • Scheduler
  • Org classroom
  • Danmaku
  • LiveChat
  • LivePlayer
  • LogViewer
  • FileTree
  • CodeReviewThread
  • VirtualList
  • InfiniteScroll
  • LogoLoop
  • BounceCards
  • CardSwap
  • ChromaGrid
  • CircularGallery
  • DomeGallery
  • FlyingPosters
  • InfiniteMenu
  • MagicBento
  • ScrollStack
  • ProfileCard
  • TiltedCard
  • PixelCard
  • DecayCard
  • ReflectiveCard
  • Folder

Charts and Diagrams

  • Flow
  • Diagram
  • Paper
  • SequenceDiagram
  • Sankey
  • Sparkline
  • Funnel
  • Treemap
  • Gantt
  • Heatmap
  • ContributionGraph
  • Legend
  • Chart
  • WorldMap

Information

  • ImageViewer
  • LiveProductCard
  • DiffStat
  • ScoreRing
  • ScoreScale
  • Badge
  • Dot
  • StatusDot
  • Chip
  • FilterChip
  • Coupon
  • Tag
  • Annotation
  • Avatar
  • AvatarCircles
  • User
  • QRCode
  • Comment
  • RelativeTime
  • GitCommit
  • DeployStatus
  • ShieldBadge
  • AwardBadge
  • CreditCard
  • IconTile

Metrics

  • Stat
  • Statistic
  • Meter
  • Timeline
  • NumberTicker

Placeholders

  • Empty
  • Skeleton
  • Watermark

Table

table

Renders sortable semantic tables with clickable rows, column headers, and empty states.

Usage

Basic usage

Just pass columns + data; the table header can be sorted by clicking, and even-numbered rows are zebra pattern by default.

WangLiuser1@hulian.devAdministrator
LiJayuser2@hulian.devEdit
ZhangJustuser3@hulian.devGuest
LiuStronguser4@hulian.devAdministrator
ChenJuanuser5@hulian.devEdit
YangGuiyinguser6@hulian.devGuest
ZhaoLeiuser7@hulian.devAdministrator
YellowTaouser8@hulian.devEdit
tsx
const columns: ColumnDef<DemoUser, any>[] = [
  { accessorKey: "name", header: "Name" },
  { accessorKey: "email", header: "Email" },
  { accessorKey: "role", header: "Role" },
];

<Table columns={columns} data={users} />

Row selection

enableRowSelection Automatically insert the check box column (including header full selection/half selection state).

WangLiuser1@hulian.devAdministrator
LiJayuser2@hulian.devEdit
ZhangJustuser3@hulian.devGuest
LiuStronguser4@hulian.devAdministrator
ChenJuanuser5@hulian.devEdit
YangGuiyinguser6@hulian.devGuest
ZhaoLeiuser7@hulian.devAdministrator
YellowTaouser8@hulian.devEdit
tsx
<Table columns={columns} data={users} enableRowSelection />

Column filter

Add meta.filterable to the column, and a built-in text filter box will appear in the header.

WangLiuser1@hulian.devAdministrator
LiJayuser2@hulian.devEdit
ZhangJustuser3@hulian.devGuest
LiuStronguser4@hulian.devAdministrator
ChenJuanuser5@hulian.devEdit
YangGuiyinguser6@hulian.devGuest
ZhaoLeiuser7@hulian.devAdministrator
YellowTaouser8@hulian.devEdit
tsx
const filterColumns = [
  { ...columns[0], meta: { filterable: true } },
  { ...columns[1], meta: { filterable: true } },
  columns[2],
];

<Table columns={filterColumns} data={users} />

Swappable filter controls and a dedicated filter row

An enum column such as Role needs a select, not a substring text box. meta.filterRender replaces the control for that column, and setting it already makes the column filterable. filterPlacement="row" then moves the controls to a dedicated row below the header, so the header keeps its single-row height and the sort button no longer shares a cell with an input.

WangLiuser1@hulian.devAdministrator
LiJayuser2@hulian.devEdit
ZhangJustuser3@hulian.devGuest
LiuStronguser4@hulian.devAdministrator
ChenJuanuser5@hulian.devEdit
YangGuiyinguser6@hulian.devGuest
ZhaoLeiuser7@hulian.devAdministrator
YellowTaouser8@hulian.devEdit
tsx
const filterRowColumns: ColumnDef<DemoUser, any>[] = [
  // Text columns keep the built-in input
  { ...columns[0], meta: { filterable: true } },
  { ...columns[1], meta: { filterable: true } },
  {
    ...columns[2],
    meta: {
      // The enum column swaps in a select; filterRender alone makes the column filterable
      filterRender: ({ value, setValue }) => (
        <Select
          items={ROLE_ITEMS}
          value={(value as string) ?? ""}
          onValueChange={(next) => setValue(next || undefined)}
        >
          <SelectTrigger size="xs" className="w-full font-normal" />
          <SelectContent>
            {ROLE_ITEMS.map((r) => (
              <SelectItem key={r.value} value={r.value}>{r.label}</SelectItem>
            ))}
          </SelectContent>
        </Select>
      ),
    },
  },
];

<Table columns={filterRowColumns} data={users} filterPlacement="row" />

Colouring cells by value (cellClassName)

Derives a class per (row, column) that lands on the <td> itself and merges with the stripe and selection classes. One column painting a different background per row is beyond both rowClassName (row state) and meta (column state), and wrapping a coloured box inside ColumnDef.cell does not work either: the cell padding still shows the td's own background.

WangLiuser1@hulian.devAdministrator
LiJayuser2@hulian.devEdit
ZhangJustuser3@hulian.devGuest
LiuStronguser4@hulian.devAdministrator
ChenJuanuser5@hulian.devEdit
YangGuiyinguser6@hulian.devGuest
ZhaoLeiuser7@hulian.devAdministrator
YellowTaouser8@hulian.devEdit
tsx
<Table
  columns={columns}
  data={users}
  cellClassName={({ columnId, value }) =>
    columnId === "role" && value === "Administrator" ? "bg-danger/10 text-danger" : undefined
  }
/>

Column geometry (column width/alignment/overflow omitted)

size / minSize / maxSize of ColumnDef directly implement the real width; meta.align / meta.headerAlign control alignment; meta.ellipsis overflows and truncates and hovers out Tooltip Read the full text. Columns that do not write size are still adaptive according to the content and will not be nailed to the same width.

WangLiuser1@hulian.devAdministratoru0001
LiJayuser2@hulian.devEditu0002
ZhangJustuser3@hulian.devGuestu0003
LiuStronguser4@hulian.devAdministratoru0004
ChenJuanuser5@hulian.devEditu0005
tsx
const columns: ColumnDef<DemoUser, any>[] = [
  { accessorKey: "name", header: "Name", size: 120 },
  { accessorKey: "email", header: "Email", size: 180, meta: { ellipsis: true } },
  { accessorKey: "role", header: "Role", size: 100, meta: { align: "center" } },
  { accessorKey: "id", header: "Number", size: 120, meta: { align: "right", headerAlign: "right" } },
];

<Table columns={columns} data={users} />

Table-level alignment (cellAlign / headerAlign)

Alignment is a whole-table decision: when an admin list has some columns centered and others left-aligned, that is almost never a design call. It is dozens of column definitions each written on their own. Set it once at the table level; a column's meta.align still wins, and the usual shape is a centered table with amount columns right-aligned (digits only line up by place value that way). headerAlign exists separately for the "centered headers, left-aligned content" layout.

WangLiAdministratoru0001
LiJayEditu0002
ZhangJustGuestu0003
LiuStrongAdministratoru0004
ChenJuanEditu0005
tsx
<Table columns={columns} data={users} cellAlign="center" />

// Set headerAlign alone when only the header should move
<Table columns={columns} data={users} headerAlign="center" />

// A column can still override it as before:
{ accessorKey: "id", header: "No.", meta: { align: "right" } }

Column width drag

resizable After turning it on, a drag handle will appear on the right edge of the meter header. Drag to change the width in real time and double-click to reset. Turn on the fixed layout (drag and drop must have a certain column width); the fixed column welt offset will be recalculated in the same frame as the column width.

WangLiuser1@hulian.devAdministratoru0001
LiJayuser2@hulian.devEditu0002
ZhangJustuser3@hulian.devGuestu0003
LiuStronguser4@hulian.devAdministratoru0004
ChenJuanuser5@hulian.devEditu0005
tsx
<Table columns={columns} data={users} resizable />

// Controlled column width (column id → pixel width), persistable to user preferences
<Table
  columns={columns}
  data={users}
  resizable
  columnSizing={sizing}
  onColumnSizingChange={setSizing}
/>

Expandable details

renderExpandedRow Renders full-width detail panels below rows.

WangLiuser1@hulian.devAdministrator
LiJayuser2@hulian.devEdit
ZhangJustuser3@hulian.devGuest
LiuStronguser4@hulian.devAdministrator
ChenJuanuser5@hulian.devEdit
YangGuiyinguser6@hulian.devGuest
ZhaoLeiuser7@hulian.devAdministrator
YellowTaouser8@hulian.devEdit
tsx
<Table
  columns={columns}
  data={users}
  renderExpandedRow={(row) => (
    <div className="text-sm text-muted-foreground">
      <div>User ID: {row.original.id}</div>
      <div>Email: {row.original.email}</div>
    </div>
  )}
/>

Row click

onRowClick makes the entire row clickable (hover highlighted + cursor-pointer + keyboard accessible); buttons/links in the row are bubbled and isolated to prevent accidental touches. For full page jump, use rowHref instead.

Actions
WangLiuser1@hulian.devAdministrator
LiJayuser2@hulian.devEdit
ZhangJustuser3@hulian.devGuest
LiuStronguser4@hulian.devAdministrator

Click any blank space in the entire line, or click the "Edit" button within the line to try

tsx
<Table
  columns={columns}
  data={users}
  onRowClick={(row) => router.push(`/users/${row.id}`)}
/>

// Or declarative whole-row navigation (whole page jump, cmd/ctrl + click to open new tab)
<Table columns={columns} data={users} rowHref={(row) => `/users/${row.id}`} />

Row drag and drop sorting

rowDraggable inserts the drag handle column forward; onRowDragEnd returns relative position semantics (activeId / overId / position), which can directly map the backend { move, target, direction } Sorting interface. The components do not change data, the order is under your control.

Name
Email
Role
WangLiuser1@hulian.devAdministrator
LiJayuser2@hulian.devEdit
ZhangJustuser3@hulian.devGuest
LiuStronguser4@hulian.devAdministrator
ChenJuanuser5@hulian.devEdit

Try dragging the leftmost handle to change the order.

tsx
<Table
  columns={columns}
  data={rows}
  getRowId={(r) => r.id}
  enableSorting={false}
  rowDraggable
  onRowDragEnd={(e) => {
    setRows(e.nextData); // Local optimistic update
    api.sortable({ // Drop library: relative position semantics
      move: e.activeId,
      target: e.overId,
      direction: e.position === "after" ? "down" : "up",
    });
  }}
/>

// The entire row can be dragged (buttons/checkboxes within the row have been gesture-isolated)
<Table columns={columns} data={rows} rowDraggable dragHandle="row" ... />

Virtual scrolling

Big data tile table open virtual, 200 rows only render viewport window (fixed height container).

tsx
<Table
  columns={columns}
  data={manyUsers}
  virtual={{ enabled: true, height: 360, rowHeight: 44 }}
/>

Cell merging

cellSpan returns a span per cell, and cells covered by an earlier span are never asked again. The callback sees render order, so merging stays aligned after sorting or filtering.

Store
Sales associate
Visits
Orders
Teemall storeZhang Min12821
Li Wei9614
Wang Fang749
Grandview storeLiu Yang15233
Chen Jing8812
tsx
<Table
  columns={columns}
  data={rows}
  cellSpan={({ rows, rowIndex, columnId }) => {
    if (columnId !== "store") return;
    // Return the whole run length at the start of the run; the rows below are merged away and never asked
    let span = 1;
    while (rows[rowIndex + span]?.store === rows[rowIndex]?.store) span += 1;
    return { rowSpan: span };
  }}
/>

Grouped headers (column groups)

Wrapping columns in a `columns` array makes a group. The group name spans its leaf columns and is centred; a column outside any group spans both header rows instead of leaving a blank cell above it. Sorting and column widths belong on the leaf columns.

Region
WeCom
Mini Program
Department
Members
Store
POS code
South ChinaSouth China Team 112Teemall storeP-0417
South ChinaSouth China Team 29Grandview storeP-0418
East ChinaEast China Team 115West Nanjing Road storeP-1102
tsx
const groupedColumns: ColumnDef<JoinRow, any>[] = [
  { accessorKey: "zone", header: "Region", size: 90 },
  {
    id: "wecom",
    header: "WeCom",
    columns: [
      { accessorKey: "dept", header: "Department", size: 140 },
      { accessorKey: "members", header: "Members", size: 110, meta: { align: "right" } },
    ],
  },
  { id: "mini", header: "Mini Program", columns: [
      { accessorKey: "store", header: "Store", size: 140 },
      { accessorKey: "pos", header: "POS code", size: 110 }] },
];

<Table columns={groupedColumns} data={rows} />

Always-visible horizontal scrollbar (scrollbar="always")

macOS overlay scrollbars are invisible until you scroll, so nothing tells the user a wide table has more columns to the right; scrollbar="always" keeps a classic scrollbar on the shell, and the browser draws none when nothing overflows. The shell also reports its real scroll state as data-overflow-left / data-overflow-right, and pinned-column shadows appear only while there is more content on that side.

Actions
WangLiuser1@hulian.devAdministratoru0001
LiJayuser2@hulian.devEditu0002
ZhangJustuser3@hulian.devGuestu0003
tsx
<Table columns={stickyColumns} data={users.slice(0, 3)} layout="fixed" scrollbar="always" />

When to use

Use Table for structured two-dimensional records with sorting, selection, trees, or virtualization. Column definitions use TanStack ColumnDef directly. Use ProTable for a complete search-toolbar-pagination page, EditableTable for editable cells, or List for a vertical item stream.

Import

ts
import { Table } from "@hulianui/ui"

// Composition primitives, for tables whose structure you write yourself
import {
  TableRoot, TableHeader, TableBody, TableFooter, TableRow, TableHead, TableCell,
} from "@hulianui/ui"

Props

NameTypeDefaultDescription
columns*ColumnDef<TData, any>[]-TanStack column definitions, including accessor, header, cell, and metadata.
data*TData[]-Row data.
enableSortingbooleantrueDisables sortable headers, arrows, and aria-sort when false.
manualSortingbooleanfalseServer-side sorting mode: keeps sortable headers, indicators, and onSortingChange, but skips client-side getSortedRowModel() re-sorting so rows render strictly in the order supplied by data.
sortingSortingState-Controlled sorting; omission uses internal state.
stripedbooleantrueApplies alternating row backgrounds.
borderedbooleantrueAdds outer border and radius; disable inside ProTable to avoid a double border.
density"default" | "middle" | "compact""default"Cell padding density.
getRowId(row: TData, index: number) => stringBy indexStable row key.
rowClassName(row: TData, index: number) => string | undefined-Additional row class merged with stripe and selection classes.
cellClassName(ctx) => string | undefined-Additional cell class landing on the <td> itself, the equivalent of the el-table cell-class-name and the antd column.onCell. ctx is { row, rowIndex, rows, columnId, columnIndex, value }, the same shape as cellSpan. Use it to colour cells by value, where one column paints a different background per row. Wrapping a coloured box inside ColumnDef.cell cannot do this: the cell padding still shows the stripe or pinned-column background underneath. Merged with the existing cell classes, never replacing them.
layout"auto" | "fixed""auto"Auto sizes only explicitly constrained columns; fixed emits every TanStack width, sums table width, and guards headers/cells against overflowing into adjacent columns (truncating overflowing text headers with a hover title, clipping cells with overflow-hidden, and defaulting unconfigured cells to break-words).
resizablebooleanfalseEnables header-edge resizing and double-click reset, forcing fixed layout.
columnSizingColumnSizingState-Controlled column widths by column id.
onRowClick(row: TData, index: number) => voidOffMakes rows pointer- and keyboard-activatable while isolating embedded controls.
rowHref(row: TData, index: number) => string | undefinedOffDeclarative full-page row navigation, with modifier-click opening a new tab.
onRowDoubleClick(row: TData, index: number) => voidOffIndependent double-click action with embedded-control isolation.
enableRowSelectionboolean | ((row: Row<TData>) => boolean)OffAdds a checkbox column and optional per-row eligibility.
rowSelectionRowSelectionState-Controlled selection state.
getRowCanExpand(row: Row<TData>) => boolean-Limits expandable rows.
getSubRows(row: TData) => TData[] | undefined-Enables tree mode; in pure tree mode the expander and row.depth indentation render inline inside the tree column (first visible data column by default) without prepending a separate expander column.
getRowHasChildren(row: TData) => boolean-Lazy tree mode: shows an expander arrow even before child rows are loaded, removing the need for placeholder children.
indentnumber16Tree indentation per level in pixels (minimum 20px rail width when treeLine is enabled).
treeLinebooleanfalseDraws continuous vertical/branch connector lines and leaf terminal dots inside the tree column (pure tree mode only).
treeColumnIdstringFirst visible data columnColumn id (ColumnDef.id or accessorKey) that hosts inline tree indentation, lines, and expander; falls back to the first visible data column when omitted or hidden.
expandedExpandedState-Controlled state shared by tree and detail expansion.
columnFiltersColumnFiltersState-Controlled column filters.
filterPlacement"header" | "row""header"Where filter controls live. header keeps them inside the header cell, next to the column name and the sort button; row moves them to a dedicated <tr> below the header row, so the header keeps its single-row height and the controls line up with the leaf columns even under grouped headers. The row is not rendered when no column is filterable.
rowDraggablebooleanfalseEnables dnd-kit row sorting; data remains controlled and the result is returned by onRowDragEnd.
dragHandle"row" | "cell""cell"Uses the entire row or a prepended handle cell.
getRowCanDrag(row: TData, index: number) => booleanAll rowsDisables dragging and drop targeting per row; nested rows are always disabled.
cellSpan(ctx) => { rowSpan?, colSpan? } | void-Cell merging, the equivalent of the el-table :span-method. The callback runs per cell and is not called for cells covered by an earlier span. ctx is { row, rowIndex, rows, columnId, columnIndex, value }, where rowIndex follows render order (after sorting and filtering) and rows is ordered the same way. It cannot be combined with virtual or renderExpandedRow; those combinations skip merging and warn in development.
stickyHeaderboolean | "self" | "scrollParent"falsePins the header row, independently of virtual. true / "self" pins it against the table's own scroll area and therefore requires maxHeight: without a height constraint the shell never scrolls, so a sticky header has no scrolling ancestor to anchor to, and the component warns in development. "scrollParent" pins it against an outer scroll container (the page or a layout content area); the table itself no longer scrolls, and the shell consequently loses overflow-x-auto (see Usage notes).
stickyHeaderOffsetnumber | string0Offset of the pinned header (numbers are pixels), emitted as the top of <thead>, so it can clear a fixed page header: stickyHeaderOffset={56}. Applies to both modes.
maxHeightnumber | string-Maximum height of the scroll area (numbers are pixels). It is what makes the shell scroll vertically; when virtual is enabled, virtual.height wins.
minWidthnumber | string-Minimum width of the <table> element itself. A min-w-* class in className pins the scroll shell instead, which stops the horizontal scrollbar from ever appearing and leaves off-screen columns clipped and unreachable.
cellAlign"left" | "center" | "right"-Table-level default for horizontal cell alignment (#292); meta.align overrides it per column. Unset keeps the historical default (left). Alignment is a whole-table decision: per-column meta.align cannot express "this table is centered", and the column you forget is the visual crack.
headerAlign"left" | "center" | "right"-Table-level default for header alignment (#292); unset follows cellAlign, while meta.headerAlign / meta.align still win per column. Setting it explicitly also overrides the "group headers are always centered" fallback for columns spanning several leaves.
cellVerticalAlign"top" | "middle" | "bottom""middle"Table-level default for cell vertical alignment; meta.verticalAlign overrides it per column.
cellWhitespace"nowrap" | "normal" | "pre-wrap"-Table-level default wrapping strategy; meta.whitespace overrides it per column. The usual shape is table-level nowrap plus a few normal columns.
virtualVirtualOptionsOffOptional virtualization: { enabled; rowHeight?=44; height?=480; overscan?=8 }.
stickyScrollbarbooleanfalseFloating horizontal scrollbar. When a wide table is taller than the viewport, a proxy scrollbar stays pinned to the bottom of the viewport so the table can be scrolled sideways without first scrolling to its last row. It appears only while the content actually overflows and the bottom edge of the table is below the fold, and it hides again once the real scrollbar comes into view. Works alongside pinned columns; it has no effect when virtual or maxHeight is set, because the shell is then a fixed-height scroll container that already shows its own horizontal scrollbar. ⚠️ Enabling it wraps the table in one extra div, because a position: sticky proxy has to be a sibling of the scroll container. className still lands on the inner scroll container, so in a flex or grid parent the wrapper is the item, not the container.
scrollbar"auto" | "always""auto"How the shell draws its horizontal scrollbar. "auto" leaves it to the browser: macOS overlay scrollbars are invisible until you scroll, so nothing tells the user there are more columns to the right. "always" applies the same classic scrollbar skin the stickyScrollbar proxy uses to the shell itself, so the bar stays visible whenever the content overflows; when nothing overflows the browser simply draws none and no height is reserved. Orthogonal to stickyScrollbar (one styles the shell's real scrollbar, the other adds a proxy once the table's bottom edge is below the fold); wide, tall tables are best with both on. Has no effect under stickyHeader="scrollParent", where the shell does not scroll horizontally.
loadingbooleanfalseLoading. It takes over the table body only while there is not a single row: it renders skeleton rows and suppresses the empty state, because on the first load the data has not arrived yet and "No data" states something nobody knows to be true. Once rows exist (paging, refresh, changed filters) this prop only sets aria-busy and the rows stay on screen; the translucent "updating" overlay is the outer layer's job (ProTable ships one).
loadingRowsnumber5Skeleton row count, used only in the "loading with no rows" case and clamped to 1..20. Pass the page size so the placeholder height matches the real table and nothing jumps once the data lands.
classNamestring-Root class name.

Events

EventTypeDescription
onSortingChangeOnChangeFn<SortingState>Sorting change.
onRowSelectionChangeOnChangeFn<RowSelectionState>Selection change.
onExpandedChangeOnChangeFn<ExpandedState>Tree or detail expansion change.
onLoadChildren(row: TData) => void | Promise<unknown>Lazy tree callback fired when expanding a row with no loaded children; shows a row-level loading spinner while the returned Promise settles, expands on resolve, and stays collapsed on reject.
onColumnFiltersChangeOnChangeFn<ColumnFiltersState>Column-filter change.
onColumnSizingChangeOnChangeFn<ColumnSizingState>Column widths, updated continuously during resize.
onRowDragEnd(e: RowDragEndEvent<TData>) => voidValid changed drop result with ids, indices, position: "before" | "after", rows, and nextData.

Slots

SlotTypeDescription
renderExpandedRow(row: Row<TData>) => ReactNodeAdds an expander and renders a full-width detail panel.
renderRowExtra(row: Row<TData>, ctx: { colSpan, rowIndex }) => ReactNodeAttaches 0..N persistent rows after each data row. It returns bare <tr> elements (an array, a fragment, or null); the component does not wrap them, so a full-width row is written as <tr><td colSpan={ctx.colSpan}>. No expander column is added and no expanded state is required. Cannot be combined with cellSpan.
footerReactNode | ((ctx: { rows, colSpan }) => ReactNode)Content of the <tfoot> element, for totals or a persistent "add a row" affordance. It follows the EditableTable.summary contract: you supply <tr><td colSpan=...> yourself, and ctx.rows holds the visible rows after sorting and filtering. Unlike summary, it also renders for an empty table.
emptyTextReactNodeEmpty-state copy, defaulting to locale.table.empty.
renderEmpty() => ReactNodeFully custom empty state, taking precedence over emptyText.

Additional ColumnDef.meta fields:

metaTypeDescriptionElement Plus equivalent
sticky"left" | "right"Pins a column and computes its offset.fixed
filterablebooleanRenders a built-in text filter in the header.-
filterRender(ctx) => ReactNodeReplaces the filter control for this column, so enum columns get a select, date columns get a date control and numeric columns get a range. ctx is { value, setValue, column }; call setValue(undefined) to clear this column's filter. Setting it already makes the column filterable, so filterable is not needed as well. The accessible name of your control is yours to provide.filters or a custom header (antd calls this filterDropdown)
align"left" | "center" | "right"Horizontal cell alignment.align
headerAlign"left" | "center" | "right"Header alignment, otherwise following align.header-align
ellipsisbooleanTruncates overflow and shows the full raw value in a tooltip.show-overflow-tooltip
verticalAlign"top" | "middle" | "bottom"Vertical alignment of the cell; header cells stay middle. A column that wraps almost always wants top.-
whitespace"nowrap" | "normal" | "pre-wrap"Wrapping strategy. pre-wrap keeps the author's line breaks and spaces and adds break-words. Mutually exclusive with ellipsis, which requires a single line.-
lockVisiblebooleanLocks visibility: the column cannot be switched off from the ProTable column-setting popover (its checkbox is checked and disabled), and a controlled columnVisibility entry of false does not apply to it either. Identity and action columns are the typical case.-
headerTooltipReactNodeHeader explanation tooltip rendered as a sibling help button outside the sort <button>, preventing invalid <button> nesting and accidental sort toggles.-
headerExtraReactNodeExtra header slot rendered as a sibling outside the sort <button> (after headerTooltip) for independent interactive controls.-

Column geometry uses TanStack ColumnDef.size, minSize, and maxSize directly. Headers and cells receive matching inline width styles without a <colgroup>.

Composition primitives

TableRoot / TableHeader / TableBody / TableFooter / TableRow / TableHead / TableCell are seven thin
wrappers for tables whose structure is written by product code and only need the library skin. The
criterion is not that Table is too weak, it is that configuration cannot express structure: two
nested levels inside one row, a row that is entirely an editor, one record split into three rows.
Expressed as ColumnDef[] those become readable table structure translated into cell callbacks,
which only reads worse. So both routes coexist: data-driven tables that need sorting, pagination, or
pinned columns use the high-level Table, everything else uses the primitives. The skin (density
steps, separators, hover, selected background) comes from the same source as the high-level Table,
so this is not a second look-alike system.

TableRoot

NameTypeDefaultDescription
density"default" | "middle" | "compact""default"Cell padding density, passed down to TableHead and TableCell through context.
stripedbooleanfalseAlternating backgrounds on TableBody rows only. The default is the opposite of the high-level Table: hand-written structures often contain full-width attached rows or merged cells, so "every other <tr>" no longer matches "every other record".
borderedbooleantrueOuter border and radius; disable it inside a card to avoid a double border.
layout"auto" | "fixed""auto"table-layout.
minWidthnumber | string-Minimum width of the <table> element itself. className lands on the scroll shell, where min-w-* would stop the horizontal scrollbar from ever appearing.
tableClassNamestring-Class name for the <table> element.
cellWhitespace"nowrap" | "normal" | "pre-wrap"-Table-level wrapping policy (#285), passed down to TableCell through context; same name and meaning as cellWhitespace on the high-level Table. Unset means the browser default (wrap). The typical shape is "table-level nowrap plus a few TableCell whitespace="normal""; TableHead is unaffected and never wraps.
cellAlign"left" | "center" | "right"-Table-level horizontal cell alignment (#292), passed down to TableCell through context; same name and meaning as cellAlign on the high-level Table. Unset means left; a per-cell TableCell align still wins.
headerAlign"left" | "center" | "right"-Table-level header alignment (#292), passed down to TableHead; unset follows cellAlign, and a per-cell TableHead align still wins.
refRef<HTMLDivElement>-The outer scroll container (the overflow-x-auto layer). Horizontal scroll state exists only there.

TableHeader, TableBody, and TableFooter accept the native <thead>, <tbody>, and <tfoot> attributes, plus a ref.

All seven primitives take a ref, each landing on its own DOM node (TableRoot on the scrolling div, the rest on thead / tbody / tfoot / tr / th / td). TableRoot matters most: horizontal scroll state lives only on that overflow-x-auto div, so a hand-drawn floating horizontal scrollbar, a ResizeObserver on the container width, "scroll to column N", and two tables scrolling in sync all need it.

tsx
const scroller = useRef<HTMLDivElement>(null)
// scrollLeft / scrollWidth / clientWidth all live on this layer
<TableRoot ref={scroller}>…</TableRoot>

TableRow / TableHead / TableCell

NameTypeDefaultDescription
selectedbooleanfalseTableRow: selected state (accent background plus data-selected, the same skin as a selected row in the high-level Table).
align"left" | "center" | "right""left"TableHead and TableCell: horizontal alignment, applied as a class rather than the deprecated HTML align attribute. Unset follows TableRoot's headerAlign / cellAlign (#292).
verticalAlign"top" | "middle" | "bottom""middle"TableCell: vertical alignment.
whitespace"nowrap" | "normal" | "pre-wrap"-TableCell: per-cell wrapping policy (#285) that overrides TableRoot's cellWhitespace; same as the column-level meta.whitespace on the high-level Table. pre-wrap / normal also apply break-words.
widthnumber | string-TableHead / TableCell: width, applied as style.width (numbers are px, strings are passed through) (#286). Use it when the column width is data (field configuration, user-editable) instead of writing style in product code. @hulianui/guard's no-style-override rejects that, dynamic w-[${px}px] classes are never compiled by Tailwind, and <col> is only reliable under layout="fixed" and cannot express maxWidth.
minWidthnumber | string-TableHead / TableCell: lower bound, applied as style.minWidth.
maxWidthnumber | string-TableHead / TableCell: upper bound, applied as style.maxWidth. truncate needs it to cap the column; otherwise auto layout lets content widen the column and the ellipsis never appears. The three mirror size / minSize / maxSize on the high-level Table; an explicit style on the element still passes through and wins.
refRef<HTMLTableRowElement | HTMLTableCellElement>-Lands on the tr / th / td itself ("scroll to this row", "measure this cell").

TableRow derives its separator, hover, and stripe treatment from the section it sits in. Header rows
do not hover, do not stripe, and do not take last:border-0, because a single header row is also the last
row, and that rule would erase the bottom border of the header. Product code never has to remember
this difference.

Usage notes

  • loading draws no overlay. It only takes over the table body in the "not a single row" case, where it renders skeleton rows; once rows exist it merely sets aria-busy. The translucent "updating" overlay comes from ProTable (which ships one) or from a wrapper of your own. The converse matters too: never let the empty state show through your own overlay, which is exactly the problem loading exists to solve (#349).
  • Skeleton rows carry data-loading-row and the whole row is aria-hidden; data rows have neither. Write liveness probes in end-to-end tests as tbody tr:not([data-loading-row]): counting tbody tr directly includes the skeleton rows, and the skeleton row count is often exactly pageSize, so "wait for N rows" is satisfied before the data ever arrives (#349).
  • Memoize columns. TanStack's flexRender renders a function cell as a component type, so a changed identity unmounts and remounts the whole cell rather than re-rendering it. On a display-only table that merely burns time; with an input inside the cell it breaks behavior: a controlled input loses focus on every keystroke and the caret jumps to the end, an onBlur submit fires on the remount blur and commits a half-typed value, and an uncontrolled input snaps back to its defaultValue and loses characters. None of those symptoms point at the columns array, so debugging usually starts by blaming the input component. For the same reason, never put a per-keystroke value in the useMemo dependencies, since that is the same as no memo. Prefer uncontrolled inputs for inline editing.
  • When forwarding primitive props through a thin wrapper, Omit the align from TableHeadProps and TableCellProps the same way they do: those interfaces replace the native align (a wider union that includes justify and char) with "left" | "center" | "right", so extending ThHTMLAttributes<…> directly is not assignable.
  • A sticky header needs stickyHeader and maxHeight: sticky positioning requires an ancestor that actually scrolls vertically, and the shell only has overflow-x-auto with no height constraint by default. Applying [&_thead]:sticky from product code cannot reach it either, because that overflow container sits in between.
  • "Horizontal scrolling inside the table plus a header pinned to the page" is not an available combination, and that is a CSS constraint rather than an implementation trade-off: overflow-x: auto makes visible on the other axis compute to auto, so that shell becomes a scrollport itself and anchors the header to it. Measured in Chromium, the header slides straight off as the page scrolls, while the same table under an overflow: visible shell stops cleanly at top: 0. stickyHeader="scrollParent" therefore drops overflow-x-auto from the shell and leaves horizontal overflow to the outer scroll container; stickyScrollbar has nothing to mirror in that mode and is ignored with a warning. Keep "self" plus maxHeight when the horizontal scroll has to stay inside the table.
  • renderRowExtra and renderExpandedRow are two different things, and the latter does not substitute for the former: a detail panel allows one row at a time, only while expanded, and always adds an expander column. "This employment period permanently carries N certificate rows" is part of the row, not a collapsible detail.
  • renderRowExtra and footer return bare <tr> elements; the component does not wrap them in <tr><td>, because wrapping would make "one attached row split into three cells" inexpressible. Always take the colSpan of a full-width row from the callback context: ctx.colSpan includes the automatically prepended selection, expander, and drag-handle columns, so a value computed from columns.length is one to three columns short and leaves a gap on the right.
  • renderRowExtra cannot be combined with cellSpan, for the same reason as renderExpandedRow: attached rows sit between data rows and a vertical span would cross them. The combination skips merging and warns in development.
  • renderRowExtra with virtual throws off the virtualizer's height estimate, which assumes one rowHeight per record when sizing its spacer rows; the symptom is drifting scroll position and blank space at the bottom. The component only warns instead of disabling the slot, because silently dropping the attached rows would be harder to diagnose than the misalignment. When the number of attached rows is fixed, set virtual.rowHeight to the combined height of the data row and its attached rows.
  • The primitives have no sorting, pagination, pinned columns, or virtualization. They are only a skin. Go back to the high-level Table for those instead of rebuilding them by hand.
  • The primitives default striped to false, the opposite of the high-level Table. Stripes count <tr> elements, and hand-written structures with attached or merged rows make that count disagree with the visual grouping of a record. Enable it explicitly once rows really are one record each.
  • Set the minimum width of a wide table through minWidth, never through className: className lands on the scroll shell, so min-w-* stops the container from shrinking, scrollWidth equals clientWidth, the horizontal scrollbar never appears, and off-screen columns are clipped and unreachable. A wide browser window hides the problem entirely.
  • meta.whitespace and meta.ellipsis are two mutually exclusive routes, because truncation requires a single line. For a review-style table that must wrap rather than truncate, combine whitespace: "normal", maxSize for the width cap, and verticalAlign: "top". Without top alignment the short cells in the row float on the middle line and no longer line up with the first line of the long ones.
  • Width styles are emitted only for explicit size, minSize, or maxSize; this avoids TanStack's default size turning every auto-layout column into equal 150 px widths.
  • Ellipsis needs a definite size, maxSize, or fixed layout. Its tooltip uses the raw string or number, not arbitrary custom-cell content.
  • Sticky offsets sum getSize(), so pinned columns are forced to that width; set size explicitly and ensure content is wide enough to scroll.
  • Resizing forces fixed layout. If summed widths are narrower than the container, min-w-full lets the browser stretch them and no horizontal scroll occurs.
  • The cellSpan callback runs only for cells that are not already covered, so the "merge while the store matches the previous row" pattern is to return the whole run length at the start of the run (while (rows[i + n]?.store === rows[i].store) n++); the following rows are never asked. The el-table [0, 0] style is also honored: returning rowSpan: 0 hides that cell.
  • cellSpan receives a rowIndex in render order (after sorting and filtering), and rows is ordered the same way. That is what avoids the classic el-table trap where enabling column sorting shifts the whole merge map: base the decision on the data, never on the original index.
  • cellClassName lands on the <td> itself and sits last in the class string, so a background or text colour it returns wins over the stripe and pinned-column colours, which is exactly what full-cell colouring needs. Do not return a bg-* class on a pinned column unless you mean to replace its opaque background. The callback also runs for the built-in leading columns (__select__, __expander__, __drag__); skip them via ctx.columnId.
  • meta.filterRender is a callback, not a component (the same contract as ColumnDef.cell): do not call hooks inside its body, keep state in your own control component. Clear a column filter with setValue(undefined), not with an empty string, which is a valid value meaning "filter by the empty string".
  • filterPlacement="row" renders that row as <td> cells inside <thead> rather than <th>: it holds controls, not column names, and header cells would be announced as a second level of column names. The row is not rendered when no column is filterable.
  • cellSpan cannot be combined with virtual or renderExpandedRow. Virtualization renders only the visible window, so a vertical span has nowhere to land, and an expanded panel inserts a <tr> between data rows that a vertical span would cross. In both cases the component skips merging and warns in development rather than rendering a misaligned table.
  • With pinned columns (meta.sticky), a horizontal span must not cross the pinned boundary: pinned offsets accumulate from the unmerged column widths, so a span across the edge misplaces the cell next to it.
  • Under grouped headers, pinning only applies to leaf columns. Offsets accumulate from leaf column widths, and a group name spanning several columns has no offset of its own, so it scrolls with the content while only the row of leaf headers below it stays at the edge. When combining grouped headers with pinned columns, keep the pinned ones outside any group -- a standalone column spans both header rows and reads the same.
  • Sorting and filtering in a grouped header live on the leaf columns; the group cell has no sort button. A group column has no accessor, so "which column is being sorted" is undefined. Enable enableSorting on the leaf you want to sort by.
  • Column widths in a grouped header belong on the leaf columns (size / minSize / maxSize). Setting them on the group does not distribute anything downward -- a group is as wide as its leaves add up to.
  • A row hidden behind a vertical span is still its own row for selection and dragging; merging is purely visual.
  • Virtualization requires optional @tanstack/react-virtual and is best for flat data, not trees, details, or drag-and-drop.
  • Disable bordered when Table sits inside another bordered card.
  • Sorting, selection, expansion, and filtering are internal unless the corresponding state and change handler are both supplied.
  • rowHref uses window.location.assign; use onRowClick with router.push for SPA navigation. onRowClick takes precedence when both exist.
  • A browser double-click emits two clicks first, so keep onRowClick reentrant when also using onRowDoubleClick.
  • Embedded interactions are isolated by semantic selectors. Give custom clickable elements an appropriate role.
  • Dragging never mutates data; write e.nextData or a server result back or the row snaps to its old place.
  • Do not combine drag order with active column sorting; filtered drag also expresses order only among visible rows.
  • Without getRowId, drag ids are array indices and cannot safely identify backend records.
  • With dragHandle="row", Space belongs to dnd-kit and Enter activates the row; use the default cell handle to avoid conflict.
  • Virtual rows outside the viewport are not drop targets and drag does not auto-page.
  • Only top-level tree rows are draggable. Use Tree for hierarchical node movement.
  • Current built-in Chinese control labels are "\u62d6\u62fd\u6392\u5e8f" (“Drag to reorder”), "\u5168\u9009" (“Select all”), "\u9009\u62e9\u884c" (“Select row”), "\u6536\u8d77" / "\u5c55\u5f00" (“Collapse” / “Expand”), "\u7b5b\u9009\u2026" (“Filter…”), dynamic "\u7b5b\u9009 <column>" (“Filter <column>”), and "\u8c03\u6574\u5217\u5bbd" (“Resize column”). emptyText also inherits the active locale.
  • The shell reports its real scroll state as data-overflow-left / data-overflow-right (present only while content is clipped on that side, removed once you reach the edge), regardless of the scrollbar value. The pinned-column divider shadows read exactly that: they show only while there is more content on that side and disappear at the edge. For a custom overflow hint, select [data-overflow-right] instead of measuring scrollWidth yourself. Under stickyHeader="scrollParent" the shell is not the scroll container, nothing is measured, and pinned columns fall back to a permanent shadow.

Related

Book3D · ProTable · PricingTable · JsonViewer · EditableTable · List

Playground

WangLiuser1@hulian.devAdministrator
LiJayuser2@hulian.devEdit
ZhangJustuser3@hulian.devGuest
LiuStronguser4@hulian.devAdministrator
ChenJuanuser5@hulian.devEdit
YangGuiyinguser6@hulian.devGuest
ZhaoLeiuser7@hulian.devAdministrator
YellowTaouser8@hulian.devEdit
<Table
  columns={columns}
  data={users}
  enableSorting={true}
  striped={true}
/>
PreviousQuestionCardData DisplayNextBook3D

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Events
    • Slots
    • Composition primitives
    • Usage notes
    • Related
  • Playground