GhostDataTable
GhostDataTable adds sorting, filtering, pagination, row selection, and expandable detail rows to a native table. For a styled table, import it and its preset renderer from @ghostvue/themes. You own the row data and fetching. The table owns the interaction state and accessible markup.
Teams that bring their own design system can compose the same behavior from @ghostvue/vue; see Advanced: headless composition. For a complete billing workflow with filters, a drawer, and toasts, open the Billing & Invoices showcase.
The phase-one architecture is recorded in ADR 0014. The full contract is the GhostDataTable specification.
Prerequisites
GhostDataTable builds on these components. Read their pages for the parts you compose:
GhostTablefor the native table, its parts, andcontain-horizontalscrolling.GhostPaginationfor the pager.GhostCheckboxfor row and select-all checkboxes.GhostInputfor search and filter fields.GhostEmptyStatefor the no-results row.
Every table needs its rows in data, its column definitions in columns, and a getRowId function. The row id keys selection, expansion, and stable rendering, and there is no index fallback. The library never clones, deep-watches, or mutates your rows.
Review invoices
A themed card preset with search, sortable columns, currency amounts, past-due invoices selected for a Mark paid action, a detail row, a Clear search recovery for no results, and a pagination footer.
The example imports every component from @ghostvue/themes. It opens on page 1 with the two past-due invoices selected, so the bulk action bar offers Mark paid straight away, and the first past-due invoice expanded to show its detail row. Try it:
- Search. Type a customer, invoice number, or status. When nothing matches, the empty state keeps the header row and the footer offers Clear search, which restores the rows and returns focus to the field.
- Sort. Focus a column heading's sort button and press
EnterorSpaceto cycle ascending, descending, and unsorted. Amounts sort as numbers and due dates as ISO dates, while cells show formatted currency and dates. - Act on a selection. Mark paid updates the selected unpaid invoices, marks the table busy with
loadingwhile the save runs, then deselects the invoices it saved. Rows you select during the save stay selected. The footer's polite status reports the result. - Open a detail. Each row's expand button shows a detail row with its own actions.
defineDataTableColumns<Invoice>() builds typed columns. Each column's accessorKey is checked against the row type and sets the column's value type, so renaming a row field breaks the column at compile time. Pass the same column array to the renderer, and the cell slot named after each column id receives a typed value. In the example, the amount cell formats its value as currency because the compiler knows it is a number. A cell slot wins over the column's cell renderer, which wins over the plain value.
The themed table offers a compact size, a bordered card surface, and sticky column headings that pin to the nearest scroll container, each set by a prop in the table below. Both renderers can also keep a wide table inside a named horizontal scroll region. The example names its region "Invoice table", so on a phone the table scrolls inside that region instead of the page.
The preset renders a labelled global search field, a selection column with a select-all checkbox, an expansion column with labelled expand buttons and detail rows, sort buttons, and an empty-state row when nothing matches. Its props name the empty state, the search field, the selection and expansion column headers, and each selection and expand control, so every label can be localized. Its slots replace a column's cells, the detail row, the toolbar, or the search field. The example replaces the search field to keep a ref to it, so Clear search can focus it. Disabled and loading state come from the parent table. The preset API lists each prop and slot.
@ghostvue/themes adds these to the headless GhostDataTable API, which it forwards:
| Prop | Type | Default | Description |
|---|---|---|---|
size | 'sm' | 'md' | "md" | Cell and control density. |
variant | 'plain' | 'card' | "plain" | Container surface. |
stickyHeader | boolean | false | Pins column headings to the block start of the nearest scroll container. |
Preset layout slots
Use layoutSlots to opt in to individual regions on either preset. For example, :layout-slots="['bulkActions', 'footer']" reserves those two names for layout on that preset. Column slots keep their existing names and cell props by default. When a column shares an enabled name, customize its cells with the column's cell renderer.
The preset has two kinds of toolbar slot. #toolbar is always on and renders before the search field and the table. #toolbarStart and #toolbarEnd render only when their names are listed in layoutSlots. Without the opt-in, a <template #toolbarEnd> is read as the cell slot of a column with the id toolbarEnd, so nothing appears. vue-tsc reports it, because the slot gets cell props until the name is enabled. The opt-in keeps a column id such as footer from ever colliding with a layout region.
<template>
<!-- invoices, columns, and exportRows come from your own script setup. -->
<GhostDataTable
:data="invoices"
:columns="columns"
:get-row-id="(row) => row.id"
aria-label="Invoices"
>
<GhostDataTablePreset :columns="columns" :layout-slots="['toolbarEnd']">
<template #toolbarEnd>
<GhostButton @click="exportRows">Export</GhostButton>
</template>
</GhostDataTablePreset>
</GhostDataTable>
</template>#toolbarStartand#toolbarEndput controls on either side of the search field. The field remains its own keyboard stop.#bulkActions="{ selectedRowIds, selectedCount, clearSelection }"appears while rows are selected. The count includes selections on other manual pages. Clearing the selection from inside the bar returns focus to the select-all checkbox when available. With query-wide selection the bar also getsselection,excludedCount,selectedCountKind,canSelectAllMatching, andselectAllMatching, and it stays open for anyqueryselection. Keep one mounted button whose label switches between the opt-in and Clear selection so focus never moves; if the focused opt-in unmounts instead, focus moves to the first control in the bar.#footer="{ pagination, pageCount, rowCount, setPageIndex }"can host a pager or query-wide row count.pagination.pageIndexis 1-based, so the first page is1.setPageIndexuses the root's normal pagination write and emits one request in manual pagination.#emptyDescriptionand#emptyActionsfill the description and actions of the empty-state row while no rows render. The title still comes fromemptyTitleatemptyHeadingLevel, so the row keeps one heading. Both render inside the row's single full-width cell, so a button there is an ordinary Tab stop after the column headers.
Clear filters from the empty state
A themed preset that opts into the emptyDescription and emptyActions layout slots: when the search and a Past due only filter match nothing, the empty row explains which filters are active and offers Clear filters, which restores every row and moves focus to the search field.
The example lists toolbarEnd, emptyDescription, and emptyActions in layoutSlots; without that opt-in those templates would not render (see Preset layout slots). It opens on a search for Lumen with Past due only checked, which matches nothing, so the empty row names the active filters and offers Clear filters. Pressing it empties the search, unchecks the status filter, and brings every invoice back.
The button lives in the empty row, so it unmounts as soon as rows return. The click handler waits for the next render and moves focus to the search field instead of leaving it on the page. Keep a ref to the field through the #search slot, as the example does, or focus another control that stays mounted.
Filter by issue date
A themed preset with start and end date pickers in the toolbarEnd slot: the issue-date column's filterFn matches inclusive, optionally open-ended bounds, Apply commits the draft through setColumnFilter, and clearing both dates commits undefined to restore every row.
The example turns on the toolbarEnd layout slot and puts two labelled GhostDatePicker fields, Issued from and Issued to, in #toolbarEnd, with Apply and Clear dates. The preset's search field is off (:show-global-filter="false"), so the date range is the only filter. Try it:
- Inclusive range. Enter Nov 14, 2026 to Nov 24, 2026 and press Apply. Both bounds match, so the two invoices issued on Nov 14 and the one issued on Nov 24 stay. The same date in both fields keeps that day only.
- Open-ended range. Leave one field empty. A start date alone keeps invoices issued on or after it; an end date alone keeps those issued on or before it.
- Clear. Empty both fields and press Apply, or press Clear dates. Every invoice comes back. A start after the end disables Apply and says why, instead of applying a range that matches nothing.
The pieces split ownership as follows:
- You pass every row.
datais the complete invoice list. The table filters it locally, so never slice rows yourself to apply a range. - The controls own the drafts. Each picker's
v-modelholds an unapplied date. Typing or picking a date changes nothing in the table until Apply. - The column owns the match. The issue-date column's
filterFnreceives the committed value and replaces the default text matcher for that column. The example commits{ from, to }as ISO dates, withnullfor an open bound, and compares them as strings, which sorts calendar days in order. - The root commits. Apply calls
setColumnFilter('issued', value)on the table's template ref, which updates its column filters. With manual filtering, that change also emitsstateChange; this example filters locally, so no request is made. When both bounds are empty it commitsundefined, which removes the filter.
The footer's polite status reads the applied range from the table's column filters model, so it announces each applied range, not every draft edit. With manual filtering, the same filter entry reaches your server in the stateChange query, and the server applies the range instead of filterFn.
Paginate long lists
The first example already pages through its footer slot. pageIndex is 1-based: the first page is 1, like GhostPagination, and unlike the 0-based page index in TanStack Table. Bind the pager to the pagination state, page count, and page setter that the footer slot provides, not to the length of your own rows. The pager then follows the filtered count (or the server's row count) and shows page 1 of 1 when nothing matches.
When the page count shrinks, the root clamps the page index to the last page. A local filter keeps the current page and clamps; it does not jump to page 1. For a pager outside a renderer, see Pagination in a manual composition.
To show every matching row at once, set :enable-pagination="false" on a local table. The root then renders the whole filtered and sorted set as one page, reports page 1 of 1, and ignores the pagination v-model, so leave the pager out. Turning pagination back on returns to the stored page. A server table (manual-pagination) ignores the option, because data is already one server page. Rendering thousands of rows is slow, so keep this for sets of modest size until row virtualization ships.
Load rows from a server
Turn on manual sorting, filtering, and pagination for each kind of work the server does. Pass one page of rows as the data and the query-wide total as the row count. The root then emits one stateChange event per user action, carrying the full query: a server filter on page 4 emits a single event that also resets the page index to 1. Fetch from the event's query only.
Guard every response with useGhostDataTableServerRequest():
const request = useGhostDataTableServerRequest()
async function onStateChange({
requestId,
query,
}: DataTableStateChangePayload) {
request.begin(requestId) // before any await
loading.value = true
try {
const page = await fetchInvoices(query)
if (!request.isLatest(requestId)) return
data.value = page.rows
rowCount.value = page.total
} finally {
if (request.isLatest(requestId)) loading.value = false
}
}A stale response, or a stale finally, then cannot overwrite a newer one. Calling retry() on the template ref re-emits the current query with a fresh request id. The headless server example also syncs the query to the URL: it reads the query string on load, pushes one history entry per committed query, and refetches after Back without letting the pending response apply. It uses the browser's history API, so it needs no router; with Vue Router, swap the small URL adapter for the route query and router.push.
Select every matching row
A themed server table with query-wide selection: select a page, extend it to all 2,300 unpaid invoices, uncheck rows on any page, and send the filter plus the excluded ids to a Mark sent action that the server resolves. Disputed invoices show a rejected action that keeps the selection.
A server table can let the operator select a page, extend the selection to every row that matches the current filters, and then uncheck rows on any page, without the app downloading 2,300 ids. Set enableQuerySelection on a root with manualPagination and manualFiltering, and bind v-model:selection. Once the visible page is fully selected and the server reports more matches, canSelectAllMatching is true and selectAllMatching() replaces the selection with a description of it:
type DataTableSelection =
| { mode: 'ids'; ids: readonly DataTableRowId[] }
| {
mode: 'query'
// Frozen snapshot of the active column filters and the global filter.
query: DataTableSelectionQuery
// Rows the operator unchecked afterwards, in order.
excludedIds: readonly DataTableRowId[]
// `rowCount` and `rowCountExact` when the operator opted in.
matchCount: number
matchCountExact: boolean
// Opaque correlation id from `selectAllMatching({ queryKey })`.
queryKey?: string
}Branch on mode when you send it. The server resolves filter minus excludeIds, authorizes the action, and runs it; the table never resolves, authorizes, or runs anything. Use the counts only as a drift check.
async function markSent(selection: DataTableSelection) {
const body =
selection.mode === 'ids'
? { ids: selection.ids }
: {
filter: selection.query,
excludeIds: selection.excludedIds,
expectedCount: selection.matchCount,
expectedCountExact: selection.matchCountExact,
}
const response = await fetch('/api/invoices/mark-sent', {
method: 'POST',
body: JSON.stringify(body),
})
if (!response.ok) {
actionError.value = await describeRejection(response) // selection kept
return
}
table.value?.resetRowSelection()
}- Rejected actions. Leave the selection as it is so the operator can exclude rows or narrow the filter, and show the reason in your own UI. The example rejects marking disputed invoices.
- Counts.
selectedCountisrowCount - excludedIds.lengthinquerymode. Membership is resolved live, so once a row is excluded the count is a lower bound:selectedCountKindis'atLeast'("At least 2,298 selected"). WithrowCountExact: false(a server estimate) it is'estimate'("About 2,300 selected"), and apageCountoverride is ignored. - What clears it. Paging, sorting, a new page of data, and
retry()keep the selection. A filter committed through the table clears it and announces "Selection cleared because the filter changed." AcolumnFiltersorglobalFilterprop change (URL restore, Back) clears it silently. The table also compares the filters before everystateChange, so a filter object edited in place clears the selection before the request goes out. - Select-all checkbox. In
querymode it still acts on the visible rows only: unchecking it excludes them. Clear selection clears everything. selectedRowIds. WhileenableQuerySelectionis on,selectionis the source of truth.selectedRowIdsis a read-only projection: the ids inidsmode and[]inquerymode, so an older bulk action that reads it acts on nothing rather than on one page. A boundselectedRowIdsis ignored with a development warning.- Filter values. The snapshot keeps strings, finite numbers, booleans,
null, arrays, and plain objects, and stores aDateas its ISO string. Other values, and row ids that areNaNor infinite, makecanSelectAllMatchingfalsewith a development warning. - Announcements.
GhostDataTablePresetandGhostDataTableTablerender a polite live region after the table. It speaks after a page becomes fully selected ("10 rows selected. All 2,300 matching rows can be selected."), after the opt-in, after Clear selection, and after a filter change. Localize it withselectionAnnouncementLabel.
Sort by several columns
A themed preset with opt-in multi-column sorting: every activation adds or cycles a column without a modifier key, rank badges and descriptions show each column's priority, and a visible Clear sorting button calls clearSorting().
Set enable-multi-sort on the root to sort by more than one column, for example status first and then the largest amount within each status. Every sortable column can take part. Array order is priority: sorting[0] is the primary sort.
- Add a column.
Shift+click,Shift+Enter, orShift+Spaceon a sort button adds that column at the lowest priority. Repeat it to flip the column from ascending to descending in place, then again to remove it. The other columns keep their direction and rank. - Plain activation. Without
Shift, the primary column advances ascending to descending on its own, and from descending clears every sort. A secondary or unsorted column starts a new sort on its own, ascending. - Without a modifier key. Touch screens have no
Shift, and screen readers in browse mode send a plain click. Pass:is-multi-sort-event="() => true"so every activation adds or cycles a column, and render a visible Clear sorting button that callsclearSorting()from the default slot or template ref, as the example does.isMultiSortEventreceives the click or key event, so it can test another modifier instead. - Cap.
max-multi-sort-col-countlimits the sorted columns. At the cap a new column is ignored, while sorted columns still cycle or leave. - Server data. With
manualSorting, each change emits onestateChangewhosequery.sortinglists the column ids and directions in priority order. In a URL, encode them as?sort=status:asc,amount:desc.
Only the primary header carries aria-sort, because that attribute cannot express rank. While more than one column is sorted, each sorted button gets a description such as "Sorted descending, priority 2 of 2", and a decorative rank badge. After each sort change a user makes, a polite live region reads the new order, such as "Sorted by Status ascending (1), then Amount descending (2).". Mounting, SSR, and a controlled sorting update stay silent. Both renderers take label props to localize the description and the announcement.
A manual composition renders these pieces itself from the default-slot bindings: the announcement text, each column's sort rank, and a clear action. Pass the description id to getSortButtonProps(columnId, { describedById }), and render the description and live region outside the <table>.
Without enable-multi-sort, sorting behaves exactly as before: one column, and Shift makes no difference.
Drill into workload by period
A themed preset that summarizes each person's known hours, unestimated assignments, availability and capacity rating for one planning period, with an Unassigned work row. Expanding a row lists its assignments; Edit opens the app's dialog editor, and a confirmed reassignment moves the hours and the assignment to the new owner.
A planner picks a period, spots an overbooked person, opens their assignments, and reassigns one. The example composes GhostDataTable and GhostDataTablePreset with a GhostSegmentedControl for the period, detail rows for the assignments, and a GhostDialog editor. Try it from the keyboard:
- Pick a period. Tab to Planning period, press
ArrowRightto reach Dec 15–26, thenSpace. Every summary and every open assignment list switches to that period. - Inspect a load. In Dec 1–12, Maya has 14 known hours against 12 available. Press
Enteron Show assignments for Maya to list the three assignments behind that total. - Reassign. Tab to Edit Release notes and press
Enter. In the editor, pressArrowDownto choose Sam, then press Tab twice, past Cancel, to reach Save and pressEnter. Once the app confirms, Maya shows 10 hours and Sam's total includes the four hours. Sam's row opens to show the assignment, and focus moves to its Edit button there, because the button that opened the editor left with Maya's list.
The example app owns every number and rule. It supplies the periods, the assignments and their estimates, each person's availability, and a capacity policy that rates known hours only. The table receives one summary row per owner for the selected period, rebuilt from the confirmed assignments, so a draft in the editor changes nothing until the save succeeds.
- Unestimated work. An assignment without an estimate is not counted as zero hours in silence. The row shows the known total and a separate count, such as Priya's 10 h and 1 unestimated, and the detail list marks the item Not estimated.
- Unassigned work. The last row groups work nobody owns yet. It shows the known effort and the unestimated count, and lists its tasks, but has no availability, so it gets no capacity rating.
- Stable rows. Row ids are owner ids, so an expanded row stays open when the period changes. Sorting is off for these columns, which keeps the unassigned row next to the people it is balanced against.
Reassignment, scheduling and saving belong to your app. GhostVue provides the table, the detail rows and the dialog, not a workload API.
Behavior
- Sorting. One column at a time unless the root sets
enableMultiSort(Sort by several columns). Each sort button cycles none, ascending, descending.aria-sortsits on the primary sorted<th>only. - Filtering. The global filter is a case-insensitive substring match across every column with an accessor (OR). Column filters combine with AND.
'',null, andundefinedclear a filter. Debouncing is yours. - Selection. With local data, select-all covers every filtered row across pages. In server mode it covers the visible rows only, and ids on other pages stay selected.
enableQuerySelectionadds an opt-in for every server match (Select every matching row). Local selection drops ids only when the sourcedatano longer contains the row, never because a filter hides it. - Expansion. Detail rows render as a second
<tr>after the data row.allowMultipleExpanded: falsekeeps one row open. - Loading and disabled.
loadingsetsaria-busyon the table.disableddisables sort, selection, and expansion controls. - Empty. Render a
GhostEmptyStatein a full-width row whenrowsis empty. Keep the header row mounted.
Accessibility
The table is a native <table>, not a grid. Tab moves between the focusable controls; there is no arrow-key cell navigation.
| Key | Control | Behavior |
|---|---|---|
Enter / Space | Sort button | Cycles the column sort. |
Shift+Enter / Shift+Space | Sort button | With enableMultiSort, adds, flips, or removes the column. |
Escape | Sort button | Does nothing. It never clears the sort. |
Space | Selection checkbox | Toggles the row or all rows. |
Enter / Space | Expand button | Opens or closes the detail. |
- Labels and ARIA state land on the focusable control (the checkbox input or the button), not on a wrapper. Icon-only header cells get a column name.
- The select-all checkbox shows a mixed state when some rows are selected.
- Give the table a name with
aria-labeloraria-labelledbyon the root. - Announcing async results is yours; add a polite live region if needed.
Advanced: headless composition
This section is for teams that bring their own design system and write their own CSS. Import the same components from @ghostvue/vue: they keep the behavior, labels, and ARIA state, and paint nothing. The examples below are also listed on the generated reference page.
Renderer child
GhostDataTableTable renders headers, sort buttons, and rows from typed columns, with a custom currency cell and GhostPagination.
Put GhostDataTableTable inside the root to render headers, sort buttons, and rows from your columns. It renders one header row, a sort button in each sortable header, and one body row per rendered row. Its columns prop also picks and orders the rendered columns.
Preset
GhostDataTablePreset renders search, sort buttons, row selection, expandable detail rows, and an empty state from typed columns, with a custom currency cell and a co-located GhostPagination.
The headless GhostDataTablePreset renders the same search, selection, expansion, and empty row as the themed first example, without a theme. Use it instead of a manual #default composition, not next to one.
Full composition
Manual GhostTable composition with sort buttons, row selection, expandable detail rows, a global search, and an empty state.
Without a renderer child, the root renders no element. Its default slot hands you tableRootProps, headers, rows, and getters for every part. Spread each getter on the matching element:
| Binding | Use on | Helper without the root |
|---|---|---|
tableRootProps | GhostTable | — |
getHeaderCellProps(columnId) | GhostTableHeaderCell (aria-sort) | getDataTableHeaderCellProps |
getSortButtonProps(columnId) | the sort <button> inside the header cell | getDataTableSortButtonProps |
getRowProps(rowId) | the data GhostTableRow | — |
getBodyCellContext(rowId, columnId) | the cell value and getValue() | — |
getHeaderSelectionCheckboxProps() | the select-all GhostCheckbox | getDataTableHeaderSelectionCheckboxProps |
getRowSelectionCheckboxProps(rowId) | each row GhostCheckbox | getDataTableRowSelectionCheckboxProps |
getRowExpandButtonProps(rowId) | each expand <button> | getDataTableRowExpandButtonProps |
detailRowProps | the detail GhostTableRow | — |
pagination, pageCount, setPageIndex | a co-located GhostPagination | — |
headerSelectionState, toggleAllRowsSelected | the select-all checkbox state | — |
sortAnnouncement | the polite live region after the table | — |
getSortIndex(columnId) | a sort rank badge or description | — |
clearSorting() | a visible Clear sorting button | — |
headers[].sortIndex, headers[].sortPriority | the 0-based and 1-based rank of a header | — |
Keep the id from getRowExpandButtonProps. When a detail row collapses while focus is inside it, the root moves focus back to that button.
For layouts without the root, the helpers in the last column return the same attributes. Each takes a useGhostDataTable return as its first argument.
Pagination in a manual composition
Manual GhostTable composition with a co-located GhostPagination bound to the root's pagination, pageCount, and setPageIndex slot bindings; searching clamps the page.
Without a renderer, bind a co-located GhostPagination to the root's pagination default-slot bindings. Searching clamps the page as described in Paginate long lists.
Server data with URL state
Server sorting, filtering, and paging synced to the URL: hydrates from the query string, pushes one history entry per committed query, ignores stale responses after Back, and recovers with retry().
This example applies the server data contract to a manual composition and syncs the query to the URL.
Styling hooks
The headless parts paint nothing. Style with the GhostTable data-part hooks plus these attributes:
data-sort="asc" | "desc"on every sorted header cell, anddata-sort-priority="1","2", and so on withenableMultiSort.data-part="sort-priority"on the decorative rank badge inside a sort button, anddata-part="sort-descriptions"anddata-part="sort-status"on the visually hidden description and live-region nodes after the table.data-selected="true"anddata-expanded="true"on data rows.data-detail-row="true"on detail rows, which keepdata-part="row".data-ghost-data-tableon the table root.
The themed sort mark follows the active column's sort state. With a manually composed table inside the themed root, add data-part="sort-button" to the sort button to opt in. The recipe supports the table's optional horizontal scroll region. A decorative child with data-part="sort-indicator" replaces the mark. During loading the header signals progress while body text and enabled controls remain at full contrast.
The sort button fills its header cell and keeps the mark next to the label, on the same edge as the column's cell text. For a numeric column, end-align the header cell and its values with text-align: end, and set justify-content: flex-end on that header's sort button. A column that holds only the selection checkbox or the expand button is as wide as that control and the cell padding.
API
GhostDataTable
| Prop | Type | Default | Description |
|---|---|---|---|
allowMultipleExpanded | boolean | true | When false, expanding one row collapses the others. |
ariaLabel | string | — | Accessible name for the table, applied through tableRootProps. |
ariaLabelledby | string | — | Id of a visible label for the table, applied through tableRootProps. |
columnFilters | DataTableColumnFilter[] | — | Declared prop columnFilters. |
columns | readonly DataTableColumnDef<TData>[] | Required | Consumer-owned column definitions. Not mutated. |
data | readonly TData[] | Required | Consumer-owned rows, read by reference only (never cloned or mutated). |
defaultColumnFilters | DataTableColumnFilter[] | — | Declared prop defaultColumnFilters. |
defaultExpandedRowIds | DataTableRowId[] | — | Declared prop defaultExpandedRowIds. |
defaultGlobalFilter | unknown | — | Declared prop defaultGlobalFilter. |
defaultPagination | DataTablePaginationState | — | Initial uncontrolled pagination. pageIndex is 1-based. |
defaultSelectedRowIds | DataTableRowId[] | — | Declared prop defaultSelectedRowIds. |
defaultSelection | DataTableSelection | — | Initial uncontrolled selection. |
defaultSorting | DataTableColumnSort[] | — | Declared prop defaultSorting. |
disabled | boolean | false | Makes sort, selection, and expansion inert and disables their controls. |
enableMultiSort | boolean | false | Opts into multi-column sorting. |
enablePagination | boolean | true | When false, a local table renders every filtered and sorted row as one page and ignores the pagination v-model (do not render a pager). Ignored with manualPagination. |
enableQuerySelection | boolean | false | Opts a server-paged, server-filtered table (manualPagination and manualFiltering) into query-wide selection: the selection v-model and selectAllMatching(). While true, selection is the source of truth, selectedRowIds is a read-only projection that is [] in query mode, and a bound selectedRowIds is ignored with a warning. |
enableRowExpansion | boolean | false | Turns on detail rows. |
enableRowSelection | boolean | false | Turns on selection. |
expandedRowIds | DataTableRowId[] | — | Declared prop expandedRowIds. |
getRowId | DataTableGetRowId<TData> | Required | Required in every build; there is no index fallback. |
globalFilter | unknown | — | Declared prop globalFilter. |
isMultiSortEvent | ((event: KeyboardEvent | MouseEvent) => boolean) | — | Whether a sort button activation adds to the sort instead of replacing it. Ignored unless enableMultiSort is true. Pass () => true for modifier-free multi-sort, paired with a visible control that calls clearSorting(). |
loading | boolean | false | Sets aria-busy="true" through tableRootProps. |
manualFiltering | boolean | false | The server filters; filter changes reset to page 1. |
manualPagination | boolean | false | When true, data is one server page and rowCount is required. |
manualSorting | boolean | false | The server sorts; the root does not reorder data. |
maxMultiSortColCount | number | — | Optional cap on sorted columns with enableMultiSort (normalized to an integer of at least 1). |
pageCount | number | — | Optional page-count override. |
pagination | DataTablePaginationState | — | Controlled pagination. pageIndex is 1-based, like GhostPagination: the first page is 1. |
rowCount | number | — | Total rows matching the query on the server. Required with manualPagination. |
rowCountExact | boolean | true | Set to false when rowCount is a server estimate: query selection counts use estimate wording and a pageCount override is ignored. Read only with enableQuerySelection. |
selectedRowIds | DataTableRowId[] | — | Declared prop selectedRowIds. |
selection | DataTableSelection | — | Controlled selection (v-model:selection). Read only with enableQuerySelection. |
sorting | DataTableColumnSort[] | — | Declared prop sorting. |
| Event | Payload | Description |
|---|---|---|
stateChange | DataTableStateChangePayload | Emitted as stateChange. |
| Slot | Slot props | Description |
|---|---|---|
default | — | Primary content. |
Sorting, column filters, the global filter, pagination, selection, and expansion each work as a v-model, with a matching default* prop for uncontrolled use. The stateChange payload carries { requestId, trigger, query } for server tables.
Template ref
The template ref exposes row, selection, expansion, sorting, filter, and pagination actions:
toggleRowSelected(rowId, value?)andtoggleAllRowsSelected(value?)change the selection, andresetRowSelection()clears it.selectAllMatching(options?)extends a fully selected page to every server match, andselection,selectedCount,selectedCountKind,canSelectAllMatching,headerSelectionState, andselectionAnnouncementread the current selection.toggleRowExpanded(rowId, value?)opens or closes a detail row.toggleSorting(columnId, multi?),setSorting(sorting), andclearSorting()change the sort.setGlobalFilter(value),setColumnFilter(columnId, value), andsetColumnFilters(filters)commit filters.setPageIndex(pageIndex),setPageSize(pageSize), andsetPagination(pagination)move between pages.getRowModel(),getPrePaginationRowModel(), andgetSelectedRowModel()read the current rows.retry()re-emits the current server query with a fresh request id.
GhostDataTablePreset
| Prop | Type | Default | Description |
|---|---|---|---|
columns | TColumns | — | Columns to render, in order, matched to the parent GhostDataTable columns by id (ids the parent does not have are skipped). Defaults to every parent column. Pass the same array you give GhostDataTable to type the #<columnId> slots. |
containHorizontal | boolean | — | When true, wraps the table in a scroll container for explicit horizontal overflow. The table itself never receives implicit overflow. |
emptyHeadingLevel | GhostEmptyStateHeadingLevel | 3 | Heading level of the empty-state title. Match the page outline (axe heading-order): one below the nearest heading above the table. |
emptyTitle | string | "No results" | Visible title of the GhostEmptyState shown when no rows render. |
expansionHeaderLabel | string | "Details" | Accessible name of the expansion column header (visually hidden text in the <th>). |
layoutSlots | readonly TLayout[] | — | Opt into the named layout slots on this preset: toolbarStart, toolbarEnd, bulkActions, footer, emptyDescription, and emptyActions. Omit to keep every layout slot name available for cells. |
rowExpansionLabel | ((rowId: DataTableRowId) => string) | "`Show details for ${String(rowId)}`" | Accessible name of a row's expand button. |
rowSelectionLabel | ((rowId: DataTableRowId) => string) | "`Select row ${String(rowId)}`" | Accessible name of a row's selection checkbox. |
scrollLabel | string | — | Accessible name for the horizontal scroll region. When omitted and a {@link GhostTableCaption } is rendered, the scroll region uses aria-labelledby on the caption id. |
searchLabel | string | "Search" | Visible label of the default search field. |
selectAllLabel | string | "Select all rows" | Accessible name of the select-all checkbox. |
selectionAnnouncementLabel | ((context: DataTableSelectionAnnouncementContext) => string) | "defaultSelectionAnnouncementLabel" | Localized polite announcement after a selection action, while the parent has enableQuerySelection (rendered outside the table). The default reads "25 rows selected. All 2,300 matching rows can be selected.", "All 2,300 matching rows selected.", "Selection cleared.", or "Selection cleared because the filter changed." |
selectionHeaderLabel | string | "Selection" | Accessible name of the selection column header (aria-label on the <th>, which holds only the select-all checkbox). |
showGlobalFilter | boolean | — | Shows the search field (or #search slot). Defaults to true when any column takes part in the global filter (an accessor and enableColumnFilter !== false). |
sortAnnouncementLabel | ((entries: readonly DataTableSortAnnouncementEntry[]) => string) | "defaultSortAnnouncementLabel" | Localized polite announcement after a user changes the sort, while the parent has enableMultiSort. Receives the new sort in priority order. |
sortDescriptionLabel | ((context: DataTableSortDescriptionContext) => string) | "defaultSortDescriptionLabel" | Localized rank description for each sort button while more than one column is sorted (aria-describedby, rendered outside the table). |
| Slot | Slot props | Description |
|---|---|---|
detail | — | Content of an expanded row's detail <tr> (one cell spanning the row). |
search | disabled: boolean, label: string, setValue: (value: string) => void, value: string | Replaces the default search field (for example to debounce input). |
toolbar | — | Rendered before the search field and the table. |
The preset also takes the layout slots in Preset layout slots and a cell slot for each column id. The detail slot receives { row, rowId, rowIndex } for the expanded row.
GhostDataTableTable
| Prop | Type | Default | Description |
|---|---|---|---|
columns | TColumns | — | Columns to render, in order, matched to the parent GhostDataTable columns by id (ids the parent does not have are skipped). Defaults to every parent column. Pass the same array you give GhostDataTable to type the #<columnId> slots. |
containHorizontal | boolean | — | When true, wraps the table in a scroll container for explicit horizontal overflow. The table itself never receives implicit overflow. |
scrollLabel | string | — | Accessible name for the horizontal scroll region. When omitted and a {@link GhostTableCaption } is rendered, the scroll region uses aria-labelledby on the caption id. |
selectionAnnouncementLabel | ((context: DataTableSelectionAnnouncementContext) => string) | "defaultSelectionAnnouncementLabel" | Localized polite announcement after a selection action, while the parent has enableQuerySelection (rendered outside the table). The default reads "25 rows selected. All 2,300 matching rows can be selected.", "All 2,300 matching rows selected.", "Selection cleared.", or "Selection cleared because the filter changed." |
sortAnnouncementLabel | ((entries: readonly DataTableSortAnnouncementEntry[]) => string) | "defaultSortAnnouncementLabel" | Localized polite announcement after a user changes the sort, while the parent has enableMultiSort. Receives the new sort in priority order. |
sortDescriptionLabel | ((context: DataTableSortDescriptionContext) => string) | "defaultSortDescriptionLabel" | Localized rank description for each sort button while more than one column is sorted (aria-describedby, rendered outside the table). |
Other exports
useGhostDataTable: the state and row models without the root, for layouts that are not tables.useGhostDataTableServerRequest: the stale-response guard.defineDataTableColumns: the typed column factory.- The five
getDataTable*Propsinteraction helpers in the composition table. - The
DataTable*andGhostDataTable*types.
Prop, slot, and event details for each component are in the API reference and the generated manifests.
Not in phase one
Virtualization, frozen columns, column resize and reorder, and grouping are out of scope. The table records a query-wide selection but never resolves it to row ids, authorizes it, or runs a bulk action. A per-column multi-sort opt-out is deferred. See the specification's non-goals.