Design System

Table reference ​

Every prop, event, slot, element and measurement across CTable, CHeaderCell and CItemCell. For the model, see Overview. For how to build one, see Usage.

Imported as CTable, CHeaderCell and CItemCell from @proxy-frontend/components, which also exposes the same three under the Table namespace alongside SortState, LayoutState, TableContext, TableInstanceRef and useInstance.

Measurements are taken at a 14px root, which is what the application pins from the interface text size setting.

Table props ​

PropTypeRequiredDefaultMeaning
labelstringyesnoneAccessible name written as aria-label on the scroll container. Never drawn
itemsT[]yesnoneThe dataset. Entries may be absent at runtime, and an absent entry draws a full-size skeleton instead of the row slot
itemHeightnumberyesnoneRow height in pixels. Read once by the virtual list, and reactively for the drawn height
selectionT[]no[]A model, so v-model:selection both seeds and receives. The default factory returns a new array
isLoadingbooleannofalseWrites aria-busy and data-is-loading, gates the loading branch, and suspends scroll bookkeeping
loadingLabelstringno""Announced in a visually hidden live region while the indicator is visible
rowKeyFn(item: T, index: number) => string | numbernoindexSupplies :key, data-id and the drag identity. The default returns the array index
rowColorFn(item: T) => Maybe<string>noundefinedReturn value is written to the row's inline backgroundColor. Any CSS colour string, with no token validation
defaultAutoscroll"top" | "bottom" | "none"no"none"The starting scroll mode. Scrolling rewrites it
draggablefalse | DraggableOptions<T, U>nofalseRow reordering. Read once during setup rather than watched

DraggableOptions holds four callbacks: onDragStart, onDragOver, onDragStop and isDraggable. The drag binds to .c-table__item-row with a 10px activation distance, and a row whose isDraggable returns false cancels the drag at start.

Table events ​

EventPayloadFires
update:selectionT[]On every change the component makes to the set
selectMaybe<T>On a plain click, on a modifier click that adds a row, and on keyboard or programmatic selection. A modifier click that removes a row and a range click with an anchor are both silent
sortSortStateOn a click on a sortable header. The cycle is asc, desc, undefined
resizeLayoutStateOn mouse release at the end of a resize gesture, not during it
scrollnumberOn a change to floor(scrollTop / itemHeight), throttled at 100ms
focus-changed(table: Table, focused: boolean)On focusin and focusout on the root

Row selection is bound to mousedown rather than to click, so it settles before a context menu opens. A right click on a row already in the set leaves the set alone, so the menu opens against the whole selection, and a modifier click cannot remove the last selected row. SortState is Maybe<{ columnId: string; direction: "asc" \| "desc" }>. LayoutState is { widths: Record<string, string> }. Table is the movement object: selectNext, selectPrev, selectPageDown, selectPageUp, selectFirst, selectLast, each returning nothing.

Table slots ​

NameSlot propsRendered
headernoneWhen supplied, as the card header band
header-rownoneWhen supplied, in a sticky wrapper at the top of the scroll container
item-row{ item: NonNullable<T> }Per visible row, skipped when the entry is absent
loadingnoneInside the loading indicator, replacing the default skeleton rows
emptynoneWhen the rendered window is empty and isLoading is false
footernoneWhen supplied, under a 1px rule at the bottom of the card
defaultnoneDeclared in the slot types and rendered nowhere. Content between the tags is discarded

Supplying header-row adds one to aria-rowcount and shifts each row's aria-rowindex from 1-based to 2-based.

Table instance ​

MemberSignature
scrollTo(index: number) => Promise<number>
currentIndexnumber
select(item: Maybe<T>) => void, which emits select without writing to the model
selectNext, selectPrevious() => void, moving within the rendered window
selectFirst, selectLast() => void, moving within the whole dataset
selectPageUp, selectPageDown() => void, moving by the visible row count

Table.useInstance<T>() returns the typed ref, and Table.TableInstanceRef<T> is its type.

Header cell props ​

PropTypeRequiredDefaultMeaning
columnIdstringyesnoneThe key under which the width is stored and read, and the identifier the sort event carries
sortablebooleannofalseAdds a pointer cursor, role="button", a tab stop, Enter and Space handling, and aria-sort
align"start" | "end"no"start"Flips the inner wrapper between flex-row and flex-row-reverse, moving the sort caret to the other side
noResizebooleannofalseRemoves the resizer element and the 1px right divider
defaultWidthstringno"4rem"Starting width. Resolved on mount to max(defaultWidth, the width the cell collapses to), which minWidth pins
minWidthstringno"4rem"Written to the inline min-width

Item cell props ​

PropTypeRequiredDefaultMeaning
columnIdstringyesnoneThe key the width is read under. An unknown key resolves to 50px
align"start" | "end"no"start"Adds text-right at end. The flex direction is unchanged

Both cell components inject the table context with optional chaining, so rendering either outside a CTable makes sorting and resizing inert, sets every cell to 50px, and throws nothing.

Vocabulary ​

AxisAccepted
sizeNot accepted by any of the three components
severityNot accepted by any of the three components
variantNot accepted by any of the three components
alignstart or end, on the two cell components

The shared axes are in components.

DOM ​

DepthElementNotes
1divw-full h-full flex, tabindex="-1", PageUp and PageDown handlers, focus handlers, forwarded attributes. No role
2CCardThree library divs, the card root, body and content, each filling its box
3divsize-full flex flex-col, holding the optional header band, the body wrapper and the optional footer band
4divflex-1 min-h-0, the card body wrapper
5divw-full h-full flex flex-col overflow-x-auto, the horizontal scroller and the drag root
6divrole="grid", with the vertical scrolling supplied by the virtual list
7divrole="row", aria-rowindex="1", sticky at the top, holding header-row
7divrole="status", aria-live="polite", sr-only, carrying loadingLabel
7divrole="presentation" for the loading branch and for the empty branch
7divrole="rowgroup", sized and offset by the virtual list
8divclass="c-table__item-row", role="row", with aria-rowindex, data-id, data-is-even, data-is-selected, data-is-draggable and inline height and background colour

CHeaderCell renders a div with role="columnheader", data-sortable, data-resizable, data-align and data-is-resizing, wrapping an inner flex container, an ellipsised label box, an optional caret box and an optional resizer. CItemCell renders a div with role="gridcell", data-column-id and data-align, wrapping an ellipsised content box.

ARIA ​

AttributeSet byValue
role="grid"The componentOn the vertical scroll container
aria-labelThe caller, through labelSupplied through the required prop rather than as an attribute
aria-rowcountThe componentitems.length, plus one when header-row is supplied
aria-busyThe componentMirrors isLoading
role="row" and aria-rowindexThe componentOn the header wrapper and on each rendered row
aria-selectedThe componentMirrors membership of the selection set
role="rowgroup"The componentOn the virtual list wrapper
role="presentation"The componentOn the loading and empty wrappers
role="status" and aria-live="polite"The componentOn the hidden loading announcer
role="columnheader" and aria-sortCHeaderCellaria-sort is absent when the column is not sortable, none when sortable and unsorted
role="gridcell"CItemCellOn the cell root
role="button" and tabindex="0"CHeaderCellOn the inner wrapper, when sortable

Forwarded attributes ​

ShapeOn CTableOn CHeaderCell and CItemCell
data-*, aria-*Reaches the rootReaches the root
on followed by a capitalReaches the rootReaches the root
id, name, formReaches the rootReaches the root
class, styleRemoved, with nothing reportedReaches the root, with class merged into the component class
title, role, tabindexRemoved with the restReaches the root

CTable sets inheritAttrs: false and filters through useForwardedAttrs, whose pattern is /^(data-|aria-|on[A-Z])|^(id|name|form)$/. Neither cell component declares defineOptions, so both keep the framework default of inheriting attributes and neither filters anything.

Measurements ​

ValueWhereSource
24pxRow height at the 14px interface defaultrowHeight(fontSize) from the tokens package
4pxRule under the sticky header row, and under the card header bandborder-b-4 border-surface-page
1pxRule under each row, and the divider on a resizable header cellborder-b and border-r, both surface-page
2pxLeading edge on a row, transparent until selectedborder-l-2, then border-l-line-selected
36pxHeader cell height8px padding, a 20px line box, 8px padding
40pxHeader row including its rule36px plus border-b-4
48pxCard header band, when the header slot is suppliedh-12 in CCard
16pxHorizontal padding in a header cell and in an item cellpx-4 against --spacing: 4px
8pxVertical padding in a header cell, and the gap before the caretpy-2 and gap-2
14pxCaret box width, and the height of a skeleton barA one em box in the header cell, and height="1rem" on the skeleton, at a 14px root
7pxVisible resizer widthHalf an em, measured against the header text rather than against the grid
31pxResizer grab area7px plus -ml-2 and -mr-4
50pxCell width when columnId matches no headerThe literal fallback in the cell
56pxDefault header width and default minimum width, at a 14px root4rem, which is also the floor the mount-time measurement returns
5Overscan rows above and below the windowThe virtual list options
10pxPointer travel before a drag startsThe drag options
300msDelay before the loading indicator appearsThe shared delayed loading composable
500msMinimum time the indicator stays once shownThe same composable
100msScroll event throttleThe scroll composable

Tokens ​

TokenUsed for
--color-surface-raisedCard background and the sticky header row background
--color-surface-subtleThe row stripe and the skeleton fill
--color-surface-pageThe rule under each row, the divider between header cells, and the 4px rules under the header band and the header row
--color-surface-hoverMixed at 75% into the hover wash
--color-fg-strongBody text from the card, and mixed at 20% into the selection wash
--color-fg-defaultHeader cell text
--color-line-selectedThe 2px leading edge on a selected row
--color-line-subtleThe rule above the footer
--z-index-stickyThe sticky header row
--z-index-raisedThe resizer

bg-black/15, painted while a sortable header is active, and border-l-transparent on the row are the two colours across the three files that come from a utility rather than from a token. The card corner is 3.5px at the 14px interface default, set by the preset and covered in card.

ComponentDifference
CTreeHierarchical rather than flat, with expansion state. CTable takes a flat array
CReorderableListDrag ordering without columns, sorting or virtualisation
CTableRowsSkeletonA placeholder drawn inside a bare CCard before the table mounts. Its one prop is rows, defaulting to 24
CCardThe shell CTable renders into, with its own header band and footer rule

Tests ​

AssertionPinned value
The rule under the sticky header rowborder-bottom-width of 4px, position of sticky, top of 0px
The grid carries the label it was givenaria-label equal to the label prop
The row count is the datasetaria-rowcount of 50 for 50 items
PageUp and PageDown suppress the browser scrolldefaultPrevented is true
The platform modifier jumps to an endMod and PageDown select the last item, Mod and PageUp select the first
Focus reports both directionsfocus-changed fires with true on focusin and false on focusout