Skip to content

GhostDataGrid ​

GhostDataGrid is an editable data grid that follows the APG data grid pattern. It renders a native table with grid semantics, a single tab stop, arrow-key movement between cells, and a labeled single-line text editor on the cells you mark editable. You own the rows: the grid never sorts, clones, or writes them. It proposes a changed value through editRequest, and your app accepts it by updating data or rejects it through cellErrors.

Import it from @ghostvue/vue. It is headless: style it through the styling hooks. The full contract is the GhostDataGrid specification.

Edit an estimate Headless

Change Build's estimate from 3 to 8: Enter proposes once, the application saves through a per-cell queue and re-sorts the rows, and focus follows Build's Estimate cell to its new row. Estimates over 20 days are rejected with a visible, announced message.

TaskOwnerEstimate
DesignAna2
BuildBen3
TestCy5

Design, owned by Ana: 2 days.

Tab into the grid, move to Build's Estimate, and press Enter. Type 8 and press Enter again. The app saves the value and re-sorts the rows, and focus follows Build's Estimate to its new row. Try 30 to see a rejection: the cell keeps its value and shows, describes, and announces the reason.

DataGrid or DataTable ​

Use GhostDataTable for reading and acting on records: sorting, filtering, pagination, selection, and detail rows. It keeps native table semantics, and Tab moves through the controls you render.

Use GhostDataGrid when people edit values in place and move between cells like a spreadsheet. A grid is one composite widget: Tab enters and leaves it, and the arrow keys move inside it. Do not wrap a read-only list in a grid to get arrow keys; screen reader users then lose the table reading commands they expect from a plain table.

Define rows and columns ​

Read-only grid Headless

A named grid with one Tab stop and arrow-key, Home/End, and Ctrl+Home/End navigation over read-only cells, with a row header column.

VersionChannelReleased
0.3.0Next2026-12-15
0.2.1Stable2026-11-30
0.2.0Stable2026-11-12

Every grid needs rows, columns, a row ID function, and an accessible name from aria-label or aria-labelledby. The row ID must stay the same across saves and reorders, because focus and open drafts follow it. Column IDs must be unique too.

Mark one column as the row header so each row starts with a row header cell. Editors are named from it ("Estimate, Build"), and screen readers announce it when moving down a column. The column options table lists how a column reads, renders, and edits its value.

Provide the empty slot. When there are no rows or columns, the grid itself becomes the named Tab stop and describes itself with that content.

Edit a cell ​

Set editable: true, or a function of the row, on a column. On an editable cell, Enter, F2, or a second press on the already active cell opens the editor with the whole value selected.

  • Enter closes the editor, returns focus to the cell, and then emits editRequest once, but only when the text changed.
  • Escape discards the draft and returns focus to the cell. It is default-prevented, so an enclosing dialog stays open; a second Escape in navigation reaches the dialog.
  • Tab and Shift+Tab emit a changed draft once and move focus out of the grid, as in a form. The edited cell becomes the re-entry target.
  • Clicking or tapping anywhere else discards the draft and leaves focus where the press put it.

The edit request names the cell and carries the previous value and the draft text, which your app parses. The editor starts from the column's toDraftText result, the value as a string by default, and "changed" means the text differs from that starting text.

Accept or reject an edit ​

Reject an edit Headless

The application leaves data unchanged and sets a cellErrors entry: the cell keeps its value, shows and announces the message, and reopens from the current value with aria-invalid.

TaskEstimate
Design2
Build3

To accept, replace data with a new array that holds the new value. You may reorder it; the grid follows the edited cell by its row and column IDs.

To reject, leave data alone and add a cellErrors entry with the row ID, column ID, and a message. Write the message as a full sentence that names the row, such as "Test estimate not saved: a task can take at most 20 days." The grid shows it in the cell, references it from the cell's description, marks the cell data-invalid="true", and announces each new entry once through its polite status element. Remove the entry on the next proposal for that cell. Reopening the editor starts from the current value and marks the editor invalid.

Saves can finish out of order. The estimate example above queues saves per cell, so the cell always ends with what the server accepted last and a newer proposal's error is never overwritten by an older save.

Lock rows and format values ​

Lock some rows Headless

editable as a per-row callback keeps done tasks reachable but read-only, and a cell render hook shows "3 days" while toDraftText opens the editor with the raw number.

TaskStatusEstimate
DesignDone2 days
BuildOpen3 days
TestOpen5 days

editable: (task) => !task.done keeps finished tasks read-only. Locked cells stay reachable with the arrow keys and expose aria-readonly="true"; Enter, F2, and a second press do nothing on them.

To show "3 days" but edit the raw number, render the display text with cell and keep toDraftText: (value) => String(value) for the editor. Set editorInputMode: 'numeric' for a number keypad on touch devices.

Right-to-left ​

Right-to-left Headless

A grid that inherits dir="rtl": ArrowLeft and ArrowRight follow the physical neighbor, Home and End follow reading order, and the editor owns caret movement.

TaskOwnerEstimate
DesignAna2
BuildBen3
TestCy5

The grid follows the page's direction. Left and right arrows move to the physical neighbor, so ArrowLeft moves forward in a right-to-left row. Home and End follow reading order, so Home reaches the rightmost cell. In the editor, arrow keys move the caret and never the active cell.

Keyboard ​

Navigation mode ​

KeyAction
Tab / Shift+TabEnter the grid on the remembered cell (first data cell on first entry, or the empty grid), or leave it.
ArrowRightPhysical right-hand neighbor in the row. Stops at the edge.
ArrowLeftPhysical left-hand neighbor in the row. Stops at the edge.
ArrowDownSame column, next row. Stops on the last row.
ArrowUpSame column, previous row. Stops on the first row.
Home / EndFirst or last cell of the row in reading order.
Ctrl+HomeFirst cell of the grid. Ctrl on every platform, including macOS.
Ctrl+EndLast cell of the grid.
Page DownSame column, forward by one fewer than the number of fully visible rows (at least one). Clamped to the last row.
Page UpSame column, back by the same step. Clamped to the first row.
Enter / F2Open the editor on an editable cell. Nothing on a read-only cell.

Every movement scrolls its target into view. Other keys are left to the browser and never move the active cell or open an editor: Space, letters, delete keys, Escape, Shift with an arrow, and Cmd chords.

Edit mode ​

KeyAction
Arrows, Home, EndMove the caret and select text. The grid does not move between cells.
EnterClose the editor, return focus to the cell, then propose a changed draft once.
EscapeDiscard the draft and return focus to the cell.
Tab / Shift+TabPropose a changed draft once and leave the grid in that direction.

While an IME composition is active, Enter and Escape belong to the IME: confirming a composition never submits, and cancelling one never discards the draft.

Pointer and touch ​

A completed click or tap on any body cell makes it the active cell and focuses it, including read-only cells. A press that turns into a scroll, or is released outside the cell, changes nothing. A second press on the active editable cell opens the editor, so a double-click opens it but a single tap never raises the on-screen keyboard by surprise.

Jump to a cell ​

Call focusCell on the template ref from a control such as a "Go to first overrun" button. It moves focus to that cell in navigation mode, discards an open draft without emitting, and never opens the editor. See the template ref table.

Behavior when data changes ​

  • Inserting or reordering rows keeps focus, and an open editor keeps its draft and selection.
  • Removing the focused row or column moves focus to the next surviving one, then the previous one. When every ID is replaced, focus moves to the first new row or column. Emptying the grid focuses the named empty grid, and the first rows you add move focus to the first cell.
  • An open draft is discarded, without emitting, when its row or column is removed, the cell becomes read-only, or toDraftText for the cell now returns different text. A new row object with the same value keeps the draft.
  • Updates while focus is outside the grid never move focus; they only change where Tab re-enters.

Accessibility ​

  • Name every grid with aria-label or aria-labelledby. Development builds warn (GHOST020) when neither is present.
  • Give each row a row header, or set editorLabel on editable columns, so every editor has a distinct name. Use editorLabel to rename or localize it, for example "Estimate for Build".
  • Write cell errors as complete sentences that make sense when read alone.
  • If you place the grid in a scroll container, give that wrapper role="region", an accessible name, and tabindex="0". Page Up and Page Down measure the visible rows through it.
  • Header cells hold text only; the grid has no sort buttons or other controls in its header in this release.
  • Automated keyboard and axe checks are not a screen reader review. NVDA with Firefox and VoiceOver with Safari reviews are required before the grid is promoted from experimental.

Styling hooks ​

HookElement
data-part="grid"The <table role="grid">. class, style, and attributes go here.
data-part="row"Header and body rows.
data-part="columnheader"Column headers.
data-part="cell"Body cells, including row headers.
data-part="editor"The text input while a cell is edited.
data-part="cell-error"The visible error message inside a cell.
data-part="empty"The cell holding the empty slot.
data-part="status"The visually hidden status element after the grid.
data-active="true"The remembered active cell.
data-editing="true"The cell whose editor is open.
data-readonly="true"Read-only cells.
data-invalid="true"Cells with a cellErrors entry.

Give cells a visible focus style, for example [data-part='cell']:focus-visible { outline: 2px solid currentColor; }. The grid renders the table and its status element side by side, so in a <style scoped> block reach its parts through a wrapper with :deep(), as the estimate example does.

Custom markup ​

useGhostDataGrid is the escape hatch for apps that must render their own grid markup. Spread each attribute bag in the table below on its element, render every row and column in the returned order, mount one editor input only for the editing cell, and render the status message in a polite status element outside the grid. GhostDataGrid is the supported path; custom markup that drops a bag or reorders cells is unsupported.

MemberUse
rows, columnsRows and columns to render, in order.
activeCell, editingCellThe remembered active cell, and the cell whose editor is open.
isEditable(cell)Whether a cell is editable now.
statusMessageText for the polite status element.
getGridProps()Attributes for the grid element.
getRowProps(rowId)Attributes for each body row.
getCellProps(cell)Attributes and handlers for each body cell.
getEditorProps()Attributes and handlers for the editor input.
focusCell(cell)Same as the component's exposed method.

API ​

PropTypeDefaultDescription
cellErrorsreadonly DataGridCellError[]"[]"App-controlled messages shown on cells; the grid never adds or clears entries.
columnsreadonly DataGridColumnDef<TData>[]RequiredColumn definitions in reading order. Column IDs must be unique.
datareadonly TData[]RequiredConsumer-owned rows in display order. Never sorted, cloned, or mutated.
getRowIdDataTableGetRowId<TData>RequiredStable row ID, as in DataTable. Focus and open drafts follow it across reorders. Row IDs must be unique.
EventPayloadDescription
editRequestDataGridEditRequestProposes a changed draft once, after Enter (the editor has closed and focus is back on the cell) or during Tab/Shift+Tab. Not emitted for unchanged drafts, Escape, focus loss, removal, or invalidation.
SlotSlot propsDescription
empty—Accessible empty-state content shown inside the empty grid.

Column options ​

OptionDescription
idUnique column ID, used in edit requests, errors, and focusCell.
headerColumn header text.
accessorKey / accessorFnReads the cell value from the row.
cellRenders display content. Receives the value, row, editable, and error.
rowHeaderRenders this column's cells as row headers. One column at most.
editabletrue, or a function of the row. Defaults to read-only.
toDraftTextText the editor starts from, and the baseline for "changed". Defaults to the value as text.
editorLabelFunction returning the editor name. Defaults to the header and row header, such as "Estimate, Build".
editorInputModeinputmode for the editor, such as numeric.
metaYour own data, passed through untouched.

Edit request ​

FieldDescription
rowIdID of the edited row.
columnIdID of the edited column.
previousValueThe cell value when the editor opened.
draftTextThe editor's text. Parse and validate it in your app.

Template ref ​

MemberDescription
focusCell(cell)Focuses the cell with { rowId, columnId } in navigation mode. Returns false if it is missing.

Not in this release ​

Custom cell editors, in-cell buttons, header controls, type-to-edit, clear-on-Delete, selection, treegrid rows, and virtualization are out of scope for 0.3.0. See the specification for what is planned to be additive.