Skip to content

GhostTable ​

GhostTable composes native <table> markup for static data. Import GhostTable from @ghostvue/themes for cell padding, row rules, header styling, and a focus ring on its scroll region; the section and cell parts come from @ghostvue/vue and stay unstyled imports. To style the table yourself, see Advanced: headless composition.

Team directory

Searchable team directory with status badges, row actions, loading and empty states, and a named horizontal-scroll region.

Team directory

5 members · 1 pending invite

MemberRoleStatusActions
ALAda LovelaceOwnerActive
GHGrace HopperAdminActive
ATAlan TuringEngineerActive
KJKatherine JohnsonAnalystInvited
EDEdsger DijkstraEngineerSuspended

Showing 5 of 5 members

The team directory wraps themed GhostTable in a GhostCard. Each member's name is a row header (scope="row"), so screen readers announce it with every cell in the row. Status uses GhostBadge and row actions use a GhostDropdownMenu whose icon-only trigger is named per member. Search filters local data; when nothing matches, a GhostEmptyState spans the body and offers to clear the search. Refresh marks the table aria-busy and swaps rows for GhostSkeleton placeholders, and a polite status announces the result once.

The table uses contain-horizontal with scroll-label="Team members". The example gives the table a 30rem minimum width through its own class, so on a phone the columns keep their alignment and the named region scrolls instead of squeezing the cells. The example styles only its own content (the member name block and the end-aligned actions column); the recipe supplies cell padding, row rules, column header styling, and a token focus ring on the region.

Row headers ​

Row headers

Themed service health table whose row headers name each record, with compact block padding for multiline rows.

Service health, last 30 days
ServiceStatus Uptime
Checkout APIHealthyNo incidents in the last 30 days.99.98%
SearchDegradedIndex rebuild in eu-west-1 is slowing queries until 18:00 UTC.99.71%
WebhooksDownDeliveries are queued. Retries resume when the broker recovers.98.42%

Put the value that identifies each record in a GhostTableHeaderCell with scope="row". Screen readers then announce "Search" with that row's status and uptime, rather than a bare "Degraded". The recipe keeps row headers at body text size and semibold, so they read as the first cell of the record rather than as part of the column header band.

The recipe centres every cell on its row, so plain text lines up with a badge, a button, or an avatar in the next cell. That suits rows of single-line values. These rows wrap, so the example sets vertical-align: baseline on its body cells: the service name and uptime then sit on the first line of the status cell. Use the same override, or top, in any table of wrapping prose.

The notes wrap, so each row is several lines tall on a phone. The example sets the cell padding to --ghost-space-inset-xs, one step down the spacing scale, so those rows stay compact and the three columns fit a 320px screen. Every other recipe value is unchanged. To make every themed control and table in a subtree compact, set data-ghost-density="compact" instead; see density.

Horizontal containment ​

Horizontal containment

Themed deployments table that scrolls inside a caption-named region instead of widening the page.

Recent deployments
ServiceRouteOwnerRegionUpdated
billing-apiPOST /v2/invoices/{invoiceId}/finalizePayments platformeu-west-12026-11-18
search-indexerPUT /v1/indexes/{indexName}/documentsDiscoveryus-east-22026-11-17
webhook-relayPOST /v1/endpoints/{endpointId}/deliveries/retryIntegrationsap-southeast-12026-11-16

The <table> itself never scrolls. A table that cannot fit its container widens the page unless you opt in with contain-horizontal. That wraps the table in a scroll container with role="region" and tabindex="0", so keyboard users can focus it and pan with the arrow keys. The page itself never scrolls sideways.

Use contain-horizontal when cells should not wrap: routes, identifiers, or columns that must stay aligned at every width. Prefer wrapping, or fewer columns, for prose. The row headers example above fits a phone without a region.

The region needs a name:

  • With a visible caption, omit scroll-label. The region uses aria-labelledby on the caption, as in this example.
  • Without a caption, for example when a card heading already titles the table, set scroll-label. The team directory uses scroll-label="Team members".

Summary table with totals ​

Summary table with totals

Themed seat usage table with row headers, a totals footer, and end-aligned tabular figures.

Seat usage by team
Team Used Seats
Design810
Engineering2430
Support66
Total3846

Column headers use smaller, muted text and a stronger divider than body rows. Row headers in the body and the GhostTableFoot total keep the body text size. Numeric columns in this sample align on the end edge with tabular figures, through a class on those cells. With containHorizontal, the scroll region shows the token focus ring, drawn inside its edge so a clipping ancestor cannot cut it off.

API ​

GhostTable ​

PropTypeDefaultDescription
containHorizontalbooleanfalseWhen true, wraps the table in a scroll container for explicit horizontal overflow. The table itself never receives implicit overflow.
scrollLabelstring—Accessible name for the horizontal scroll region. When omitted and GhostTableCaption is rendered, the scroll region uses aria-labelledby on the caption id.
SlotSlot propsDescription
default—GhostTableCaption, GhostTableHead, GhostTableBody, and GhostTableFoot content.

@ghostvue/themes adds no props, events, or slots to the headless GhostTable API, which it forwards.

Native attributes fall through to the <table> element. Exposes element: HTMLTableElement | null.

Parts ​

ComponentElementProps
GhostTableCaptioncaptionfallthrough
GhostTableHeadtheadfallthrough
GhostTableBodytbodyfallthrough
GhostTableFoottfootfallthrough
GhostTableRowtrfallthrough
GhostTableHeaderCellthscope?: 'col' | 'row' | 'colgroup' | 'rowgroup'
GhostTableCelltdfallthrough

Each part exposes element for its native host.

Accessibility ​

Use GhostTableCaption when the table needs a name. Set scope on GhostTableHeaderCell when header relationships are not implicit. Sorting, filtering, and selection are out of scope; compose controls inside cells when needed. For sorting, selection, and paging built in, see GhostDataTable.

Advanced: headless composition ​

The headless parts from @ghostvue/vue render the same native markup with no styles. Use them with your own table CSS, or use the useGhostTable* composables to bind the contract to elements you already render.

Headless table ​

Always place rows inside GhostTableHead, GhostTableBody, or GhostTableFoot. Explicit <tbody> avoids browser-inserted section mismatches during SSR hydration.

Basic table Headless

Caption, header row, and explicit tbody semantics.

Q3 2025 invoices
InvoiceStatusAmount
INV-1042Paid$420.00
INV-1043Due$128.50

Composable use ​

Composable Headless

Native table hosts with useGhostTable hooks.

PlanSeats
Pro12

Styling hooks ​

Hooks follow existing data-part conventions:

  • ghost-table / data-part="root" / data-ghost-table on the table
  • ghost-table-scroll-container / data-part="scroll-container" when containment is enabled
  • Section and cell classes: ghost-table-head, ghost-table-body, ghost-table-row, etc.

Specification: GhostTable specification.