SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

Table

A tabular data display built on the native <table>.

MonitorStatusRegionResponseUptime (30d)Last checkedActions
api.acme.devUpFrankfurt142 ms99.98%
checkout.acme.devDegradedN. Virginia912 ms99.21%
webhooks.acme.devDownSão Paulo—96.12%
cdn.acme.devCheckingSydney64 ms99.95%
docs.acme.devPausedOregon—99.99%
View code
tsx
<Table.Container>
	<Table aria-label="Monitors">
		<Table.Header>
			<Table.Row>
				<Table.SelectAll label="Select all monitors" />
				<Table.Column>Monitor</Table.Column>
				<Table.Column>Status</Table.Column>
				<Table.Column>Region</Table.Column>
				<Table.Column numeric>Response</Table.Column>
				<Table.Column numeric>Uptime (30d)</Table.Column>
				<Table.Column>Last checked</Table.Column>
				<Table.ActionsColumn label="Actions" />
			</Table.Row>
		</Table.Header>
		<Table.Body>
			{monitors.map((monitor) => (
				<Table.Row key={monitor.id}>
					<Table.Select name="monitor" value={monitor.id} label={`Select ${monitor.name}`} />
					<Table.Cell>
						<Table.RowLink href={`/monitors/${monitor.id}`}>{monitor.name}</Table.RowLink>
					</Table.Cell>
					<Table.StatusCell color={monitor.status.color} pulse={monitor.checking}>
						{monitor.status.label}
					</Table.StatusCell>
					<Table.Cell>{monitor.region}</Table.Cell>
					<Table.NumberCell
						value={monitor.responseMs}
						locale="en"
						format={{ style: "unit", unit: "millisecond" }}
					/>
					<Table.NumberCell
						value={monitor.uptime}
						locale="en"
						format={{ style: "percent", minimumFractionDigits: 2 }}
					/>
					<Table.DateCell date={monitor.checkedAt} now={requestTime} locale="en" />
					<Table.Actions overflowLabel="More actions">
						<Table.Action>Pause</Table.Action>
						<Table.Action danger>Delete</Table.Action>
					</Table.Actions>
				</Table.Row>
			))}
		</Table.Body>
	</Table>
</Table.Container>

Demo apps

Whole pages built only from @sdxc/ui, each for an invented product with its own palette and type. They open in a new tab.

Every demo, landings and docs sites alike, is listed in the showcase.

Installation

An ordinary dependency: install it, import the theme once, and import the component where it is used.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Usage

typescript
import { Table } from "@sdxc/ui/app";

Renders the <table> host: full width, border-collapsed, small text. density sets the row height, pinFirstColumn keeps the first column in view with a scroll-driven edge shadow, and aria-busy="true" dims the body while it refetches. Dev mode warns without a name.

Composition

The parts the component publishes, each a static property of the host.

  • Table
  • Table.ContainerRenders the scrolling wrapper around Table: the table scrolls sideways inside it instead of widening the page, and the header sticks to its own top edge, whatever sticky offset the page around it sets.
  • Table.HeaderRenders the <thead> host, whose header cells stick at --ui-app-sticky-top (below an app's own sticky bar) over an opaque surface, ruled from the body by an inset line that stays with them as they stick.
  • Table.BodyRenders the table's <tbody> host: a block-start border rules the space between direct row children, and content-visibility: auto lets a long body's off-screen rows skip layout and paint until they scroll into view.
  • Table.ColumnRenders a column header inside a native <th scope="col">, aligned by data-align.
  • Table.SortLinkThe sortable header's cell-filling link, followed by its direction indicator held square, so a header narrow enough to squeeze the link keeps both arrows legible.
  • Table.RowRenders a native <tr> host at the density's block size.
  • Table.CellRenders a native <td> host, padded on every side and colored as the table's emphasized foreground text; a numeric cell end-aligns tabular figures.
  • Table.KeysTurns on keyboard row navigation for a server-rendered table: j/k and the arrows move through the rows with an inset ring, Enter or o opens the row's link, x toggles its checkbox and / focuses the search field.
  • Table.SelectAllRenders the selection column's header: a select-all checkbox marked data-selection-all, and the TableSelection island that makes it check every row, show indeterminate while some are, and lets shift-click check a range.
  • Table.SelectRenders one row's selection checkbox, marked data-selection-item with the row's key as its value, so it submits with a form and any selection bar can count it.
  • Table.ActionsColumnRenders the header over the row actions with its name visually hidden, since the buttons beneath name themselves.
  • Table.ActionsRenders a row's actions on one line.
  • Table.ActionRenders one row action as a small neutral ghost button, or a danger one with danger; inside the overflow menu of Table.Actions it renders as a menu row instead, so an app writes each action once and both forms carry it.
  • Table.RowLinkRenders the link to a row's record, usually the name in the first cell; its hit area covers the whole row, and its focus ring outlines the row.
  • Table.NumberCellRenders a number through Intl.NumberFormat, end-aligned in tabular figures.
  • Table.CurrencyCellRenders an amount in its currency's symbol with the ISO code muted after it ("€123.00 EUR"), end-aligned in tabular figures so amounts in mixed currencies still line up.
  • Table.IdCellRenders an id in mono, ellipsised in the middle so its last characters stay visible.
  • Table.DateCellRenders a moment through RelativeTime: "2m ago" within a week, a date after it, the exact local and UTC time in its title.
  • Table.StatusCellRenders a state as a StatusDot and its label, with any Table.StatusDetail after the name, the whole label on one line.
  • Table.StatusDetailDetail after a status's name, muted past a middle dot on the same line, such as a date or a code.
  • Table.BarCellRenders a figure over a bar sized to value / max, so the column reads as a bar chart while every figure stays exact.
  • Table.EmptyRenders what a table with no rows shows: any content, laid out beneath the table's header and outside the <table>, so the column names stay as context for what is missing.
  • Table.ErrorRenders a failure in place of Table.Body: the message and a Retry control centred across every column, announced as an alert, so the header and the page around it stay put.
  • Table.ErrorMessageWhat went wrong, set beside the Retry control in a failed table's alert.
  • Table.LoadMoreRenders a trailing row carrying a single link that spans every column, standing in for an auto-loading "next page" trigger since fetching more rows without a full navigation requires script a consumer attaches.
  • Table.LoadMoreLinkThe trailing row's link to the next page, centred and muted until hovered.

Examples

Selection with select-all and shift-click ranges

View code
tsx
<form id="bulk-posts" method="post" action="/posts/bulk" />

<Table.Container>
	<Table aria-label="Drafts">
		<Table.Header>
			<Table.Row>
				<Table.SelectAll label="Select all drafts" />
				<Table.Column>Title</Table.Column>
				<Table.Column>Author</Table.Column>
				<Table.Column numeric>Words</Table.Column>
			</Table.Row>
		</Table.Header>
		<Table.Body>
			{posts.map((post) => (
				<Table.Row key={post.id}>
					<Table.Select
						name="post"
						value={post.id}
						form="bulk-posts"
						checked={post.selected}
						label={`Select ${post.title}`}
					/>
					<Table.Cell>
						<Table.RowLink href={`/posts/${post.id}/edit`}>{post.title}</Table.RowLink>
					</Table.Cell>
					<Table.Cell>{post.author}</Table.Cell>
					<Table.NumberCell value={post.words} locale="en" />
				</Table.Row>
			))}
		</Table.Body>
	</Table>
</Table.Container>

Typed cells: a payments list

PaymentCustomerAmountFeeStatusCreated
pi_3QbX9f2eZvKYlo2C1x8T4aRwNorthwind Traders$1,280.00USD$37.42USDSucceeded
pi_3QbWzA2eZvKYlo2C0m1Pq7LdAcme Design GmbH€480.00EUR—Pending
pi_3QbR1c2eZvKYlo2C1s9Hk2MnGlobex$39,000.75USD$1,131.32USDSucceeded
pi_3QaZ0d2eZvKYlo2C0v4Bf8XyInitech Ltd£96.00GBP£2.98GBPRefunded
pi_3QYm7e2eZvKYlo2C1c3Dg5JzHooli$740.00USD—Failed
View code
tsx
<Table.Container>
	<Table aria-label="Payments">
		<Table.Header>
			<Table.Row>
				<Table.Column>Payment</Table.Column>
				<Table.Column>Customer</Table.Column>
				<Table.Column numeric>Amount</Table.Column>
				<Table.Column numeric>Fee</Table.Column>
				<Table.Column>Status</Table.Column>
				<Table.Column>Created</Table.Column>
			</Table.Row>
		</Table.Header>
		<Table.Body>
			{payments.map((payment) => (
				<Table.Row key={payment.id}>
					<Table.IdCell value={payment.id} />
					<Table.Cell>{payment.customer}</Table.Cell>
					<Table.CurrencyCell value={payment.amount} currency={payment.currency} locale="en" />
					<Table.CurrencyCell value={payment.fee} currency={payment.currency} locale="en" />
					<Table.StatusCell color={payment.status.color}>{payment.status.label}</Table.StatusCell>
					<Table.DateCell date={payment.createdAt} now={requestTime} locale="en" />
				</Table.Row>
			))}
		</Table.Body>
	</Table>
</Table.Container>

Compact and comfortable rows

CustomerSubjectStatusUpdated
Maya ChenWebhook retries stopped after the plan changeOpen
Tomás HerreraInvoice shows the old company addressWaiting
Priya NatarajanCan we export check history as CSV?Solved
CustomerStatusUpdated
Maya Chen
Webhook retries stopped after the plan change
Open
Tomás Herrera
Invoice shows the old company address
Waiting
Priya Natarajan
Can we export check history as CSV?
Solved
View code
tsx
<Table aria-label="Inbox, compact" density="compact">…</Table>

<Table aria-label="Inbox, comfortable" density="comfortable">
	…
	<Table.Cell>
		<Table.RowLink href={`/inbox/${conversation.id}`}>{conversation.customer}</Table.RowLink>
		<div>{conversation.subject}</div>
	</Table.Cell>
	…
</Table>

Empty, failed and refetching

NameOwnerSubscribers

No status pages yet

Publish one to tell customers what is up before they ask.

NameOwnerSubscribers
NameOwnerSubscribers
status.acme.devPlatform4,210
pay.acme.devPayments1,388
View code
tsx
<Table.Container>
	<Table aria-label="Status pages">
		<Table.Header>…</Table.Header>
	</Table>
	<Table.Empty>
		<p>No status pages yet</p>
		<p>Publish one to tell customers what is up before they ask.</p>
	</Table.Empty>
</Table.Container>

<Table aria-label="Incidents">
	<Table.Header>…</Table.Header>
	<Table.Error colSpan={3}>
		<Table.ErrorMessage>Incidents could not load. Request 7f3a2c91.</Table.ErrorMessage>
		<LinkButton href={currentUrl} size="sm" variant="outline">Retry</LinkButton>
	</Table.Error>
</Table>

<Table aria-label="Deploys" aria-busy={refreshing ? "true" : undefined}>…</Table>

Pinned first column and data bars

RouteRequestsErrorsP75P99Transferred
/api/checks1.3M0.12%48 ms212 ms9.4 GB
/api/monitors/:id642K0.04%31 ms140 ms2.1 GB
/status/:slug402K0%22 ms96 ms6.8 GB
/api/incidents88K3.1%120 ms940 ms0.32 GB
/webhooks/stripe12K0.81%210 ms1,480 ms0.04 GB
View code
tsx
<Table.Container>
	<Table aria-label="Routes, last 24 hours" pinFirstColumn>
		<Table.Header>
			<Table.Row>
				<Table.Column>Route</Table.Column>
				<Table.Column numeric>Requests</Table.Column>
				<Table.Column numeric>Errors</Table.Column>
				<Table.Column numeric>P75</Table.Column>
				<Table.Column numeric>P99</Table.Column>
				<Table.Column numeric>Transferred</Table.Column>
			</Table.Row>
		</Table.Header>
		<Table.Body>
			{routes.map((route) => (
				<Table.Row key={route.path}>
					<Table.Cell>{route.path}</Table.Cell>
					<Table.BarCell value={route.requests} max={busiest} locale="en" format={{ notation: "compact" }} />
					<Table.NumberCell value={route.errorRate} locale="en" format={{ style: "percent", maximumFractionDigits: 2 }} />
					<Table.NumberCell value={route.p75Ms} locale="en" format={{ style: "unit", unit: "millisecond" }} />
					<Table.NumberCell value={route.p99Ms} locale="en" format={{ style: "unit", unit: "millisecond" }} />
					<Table.NumberCell value={route.gigabytes} locale="en" format={{ style: "unit", unit: "gigabyte", maximumFractionDigits: 2 }} />
				</Table.Row>
			))}
		</Table.Body>
	</Table>
</Table.Container>

Sorting through URLs

InvoiceCustomerIssuedStatusTotal
INV-2041Northwind Traders12 Seppaid$1,280.00
INV-2040Acme Design11 Sepopen$480.00
INV-2039Globex9 Sepoverdue$3,900.00
INV-2038Initech4 Seppaid$96.00
INV-2037Hooli1 Seppaid$740.00
Load the next 25 invoices
1 of 5 selected
View code
tsx
let selection = new SelectionModel({ mode: "multiple", keys, selectedKeys: ["INV-2039"] });
selection.addEventListener("change", () => void handle.update());

// The headers link, so the order is whatever the query asks for. An app would serve
// the page back sorted; a page that is its own server writes the query and re-reads it.
let sort = readSort(globalThis.location?.search ?? "");

function sortFromHeader(event) {
	let link = event.target.closest('th[aria-sort] a');
	if (!link) return;

	event.preventDefault();
	globalThis.history.pushState(null, "", link.href);
	sort = readSort(globalThis.location.search);
	void handle.update();
}

// Only the active column carries a direction; the rest show the idle indicator.
let direction = (key) => (sort.key === key ? sort.direction : undefined);

<div mix={[on("click", sortFromHeader)]}>
	<Table.Container>
		<Table aria-label="Invoices">
			<Table.Header>
				<Table.Row>
					<Table.Column>
						<Checkbox
							aria-label="Select every invoice"
							checked={selection.isAll}
							mix={[on<HTMLInputElement, "change">("change", toggleAll)]}
						/>
					</Table.Column>
					<Table.Column sortDirection={direction("id") ?? "none"}>
						<Table.SortLink href={sortHref("id", sort)}>Invoice</Table.SortLink>
					</Table.Column>
					<Table.Column sortDirection={direction("customer") ?? "none"}>
						<Table.SortLink href={sortHref("customer", sort)}>Customer</Table.SortLink>
					</Table.Column>
					<Table.Column sortDirection={direction("issued") ?? "none"}>
						<Table.SortLink href={sortHref("issued", sort)}>Issued</Table.SortLink>
					</Table.Column>
					<Table.Column>Status</Table.Column>
					<Table.Column align="end" sortDirection={direction("total") ?? "none"}>
						<Table.SortLink href={sortHref("total", sort)}>Total</Table.SortLink>
					</Table.Column>
				</Table.Row>
			</Table.Header>
			<Table.Body>
				{sortInvoices(invoices, sort).map((invoice) => (
					<Table.Row
						key={invoice.id}
						aria-selected={selection.isSelected(invoice.id) ? "true" : undefined}
					>
						<Table.Cell>
							<Checkbox
								aria-label={`Select ${invoice.id}`}
								checked={selection.isSelected(invoice.id)}
								mix={[
									on<HTMLInputElement, "change">("change", () => selection.toggle(invoice.id)),
								]}
							/>
						</Table.Cell>
						<Table.Cell>{invoice.id}</Table.Cell>
						<Table.Cell>{invoice.customer}</Table.Cell>
						<Table.Cell>{invoice.issuedLabel}</Table.Cell>
						<Table.Cell>
							<Badge color={statusColors[invoice.status]} variant="secondary">
								{invoice.status}
							</Badge>
						</Table.Cell>
						<Table.Cell>{invoice.totalLabel}</Table.Cell>
					</Table.Row>
				))}
				<Table.LoadMore colSpan={6}>
					<Table.LoadMoreLink href="?page=2">Load the next 25 invoices</Table.LoadMoreLink>
				</Table.LoadMore>
			</Table.Body>
		</Table>
	</Table.Container>
	<div mix={[hstack({ gap: 2, align: "center", justify: "end" })]}>
		<Text>
			{selection.size} of {invoices.length} selected
		</Text>
	</div>
</div>

Props

Read from the component's own types, so every prop, every default and every allowed value is listed.

PropTypeDefaultRequiredDescription
density"compact" | "comfortable"—NoRow height, exposed as data-density and --ui-table-row-block-size.
pinFirstColumnboolean—NoKeeps the first column in view while the table scrolls sideways in its container, with an edge shadow that appears once anything has scrolled beneath it.

Also accepts everything in TagProps<"table">.

Table.Container

Also accepts everything in TagProps<"div">.

Table.Header

Also accepts everything in TagProps<"thead">.

Table.Body

Also accepts everything in TagProps<"tbody">.

Table.Column

PropTypeDefaultRequiredDescription
align"start" | "center" | "end"—NoText alignment for the header and its indicator. Defaults to DEFAULT_ALIGN, or DEFAULT_NUMERIC_ALIGN for a numeric column.
numericboolean—NoMarks the column as holding numbers, exposed as data-numeric: the header aligns to the end unless align says otherwise, matching numeric cells beneath it.
sortDirectionSortDirection | "none"—NoThis column's sort direction: ascending or descending when it is the active sort key, none when it sorts but is not active. Omit it for an unsortable column.

Also accepts everything in Omit<TagProps<"th">, "align">.

Table.Row

Also accepts everything in TagProps<"tr">.

Table.Cell

PropTypeDefaultRequiredDescription
numericboolean—NoMarks the cell as a number, exposed as data-numeric: its figures render at tabular widths and align to the end, so digits line up down the column.

Also accepts everything in TagProps<"td">.

Table.Keys

Table.SelectAll

PropTypeDefaultRequiredDescription
labelstring—YesAccessible name of the select-all checkbox, such as "Select all monitors".
checkedboolean—NoWhether every row starts selected.

Also accepts everything in Omit<TagProps<"th">, "children">.

Table.Select

PropTypeDefaultRequiredDescription
valuestring—YesThe row's key, submitted as the checkbox's value.
labelstring—YesAccessible name, such as "Select api.example.com".
namestring—NoField name the checked keys submit under.
formstring—NoId of a <form> elsewhere on the page the checkbox submits with, such as a bulk-action form.
checkedboolean—NoWhether the row starts selected.
disabledboolean—NoKeeps the row out of the selection and out of select-all.

Also accepts everything in Omit<TagProps<"td">, "children">.

Table.ActionsColumn

PropTypeDefaultRequiredDescription
labelstring—YesThe column's name for assistive technology, such as "Actions".

Also accepts everything in Omit<TagProps<"th">, "children">.

Table.Actions

PropTypeDefaultRequiredDescription
overflowLabelstring—NoName of the menu button that stands in for the actions in a narrow table, such as "More actions", which then lists Table.Action children as menu rows. Without it, the button takes Table.ActionsColumn's label and opens the actions as they are.

Also accepts everything in TagProps<"td">.

Table.Action

Also accepts everything in Menu.ItemProps.

Table.NumberCell

PropTypeDefaultRequiredDescription
valuenumber | null | undefined—YesThe value; null or undefined renders —.
localestring—NoBCP 47 locale. Defaults to the runtime's.
formatIntl.NumberFormatOptions—NoFormatting, such as { style: "unit", unit: "millisecond" } or { style: "percent" }.

Also accepts everything in TypedCellProps.

Table.CurrencyCell

PropTypeDefaultRequiredDescription
valuenumber | null | undefined—YesThe amount in major units (12.8 for $12.80); null or undefined renders —.
currencystring—YesISO 4217 code, such as "USD".
localestring—NoBCP 47 locale. Defaults to the runtime's.

Also accepts everything in TypedCellProps.

Table.IdCell

PropTypeDefaultRequiredDescription
valuestring | null | undefined—YesThe full id, kept whole in the text and the title; null or undefined renders —.
tailnumber—NoCharacters kept after the ellipsis, always whole: the cell outgrows --ui-table-id-max-inline-size as far as they need. Defaults to DEFAULT_ID_TAIL.

Also accepts everything in TypedCellProps.

Table.DateCell

PropTypeDefaultRequiredDescription
dateDate | string | number | null | undefined—YesThe moment; null or undefined renders —.
nowDate | string | number—NoReference moment, so the server renders deterministically.
localestring—NoBCP 47 locale.
timeZonestring—NoIANA zone the server formats in. Defaults to UTC.
localboolean—NoRewrites the time in the viewer's zone through the RelativeTimeLocal island.

Also accepts everything in TypedCellProps.

Table.StatusCell

PropTypeDefaultRequiredDescription
color"brand" | "neutral" | "success" | "warning" | "danger"—NoSemantic role of the state.
pulseboolean—NoMarks a state still in progress, so its dot pulses.
childrenRemixNode—NoThe state's name, then any Table.StatusDetail; omit it and the cell renders —.

Also accepts everything in Omit<TagProps<"td">, "color">.

Table.StatusDetail

Also accepts everything in TagProps<"span">.

Table.BarCell

PropTypeDefaultRequiredDescription
valuenumber | null | undefined—YesThe value; null or undefined renders —.
maxnumber—NoThe value a full bar stands for. Defaults to DEFAULT_BAR_MAX.
localestring—NoBCP 47 locale for the figure.
formatIntl.NumberFormatOptions—NoFormatting for the figure.
color"brand" | "neutral" | "success" | "warning" | "danger"—NoThe bar's role colour. Defaults to neutral.

Also accepts everything in TypedCellProps.

Table.Empty

Also accepts everything in TagProps<"div">.

Table.Error

PropTypeDefaultRequiredDescription
colSpannumber—YesNumber of columns the table renders, so the message spans the full row width.
childrenRemixNode—YesWhat went wrong, as a Table.ErrorMessage, then a Retry control.

Also accepts everything in TagProps<"tbody">.

Table.ErrorMessage

Also accepts everything in TagProps<"span">.

Table.LoadMore

PropTypeDefaultRequiredDescription
colSpannumber—YesNumber of columns the surrounding table renders, so the link spans the full row width.
childrenRemixNode—YesA Table.LoadMoreLink.

Also accepts everything in TagProps<"tr">.

Types

NameValuesWhat it decides
Align"start" | "center" | "end"Text alignment for a column's header and, by convention, its cells.
SortDirection"ascending" | "descending"Current sort direction for a sortable column, matching the values the native aria-sort attribute accepts.
Density"compact" | "comfortable"Row height: compact is 2.5rem for scanning, comfortable 3.5rem for two-line rows.
@sdxc/ui

Can’t find it? Contact us