GhostTabs specification
Status: Proposed for GHO-29. Spec and implementation ship together; Zac approves both in PR review.
Amendment (approved 2026-12-03): a
variantprop on the themedGhostTabsContentis recorded in the Content variant amendment. The maintainer @zprue743 approved it in PR review on 2026-12-03.
Amendment (approved 2026-12-03): a
sizeprop on the themedGhostTabsListis recorded in the Control size amendment. The maintainer @zprue743 approved the recommended contract decision (Q1–Q4) on 2026-12-03.
Purpose and user problems
GhostTabs groups related views behind a shared tab list so users can switch panels without navigating away. Settings screens, record detail layouts, and dashboard sections need one focusable tab strip, clear tab / tabpanel semantics, and predictable arrow-key movement. The component composes useControllableState, useGhostId, and useRovingFocus so applications get APG-correct tabs with automatic or manual activation, horizontal or vertical orientation, and controlled or uncontrolled selection without reimplementing roving tabindex or SSR-safe IDs.
Non-goals
- Accordion-style single-expand panels (
GhostAccordion/GhostCollapsible). - Toolbar or menubar composites (
GhostToolbar,GhostDropdownMenu). - Routed URL synchronization or deep-link tab state (consumer-owned).
- Animated panel transitions or lazy/async panel loading orchestration.
- Tab close buttons, overflow menus, or drag-and-drop reordering.
Public API
Parts and exports
Headless exports from @ghostvue/vue:
GhostTabs(root state and context provider; renderless)GhostTabsList(role="tablist"host with roving focus)GhostTabsTrigger(role="tab"control)GhostTabsContent(role="tabpanel"region)useGhostTabs(composable returning selection state, registries, and helpers)- Types:
GhostTabsProps,GhostTabsSlotProps,GhostTabsListProps,GhostTabsTriggerProps,GhostTabsContentProps,GhostTabsListExposed,GhostTabsTriggerExposed,GhostTabsContentExposed,GhostTabsExposed,UseGhostTabsOptions,UseGhostTabsReturn,GhostTabsActivationMode,GhostTabsOrientation
Themed exports from @ghostvue/themes:
GhostTabs,GhostTabsList,GhostTabsTrigger,GhostTabsContent(plus re-exported types and styles viadefault.css)
Props and configuration
GhostTabs (root)
| Prop | Type | Default | Contract |
|---|---|---|---|
modelValue | string | undefined | undefined | Controlled selected tab value. Omit for uncontrolled mode. |
defaultValue | string | undefined | undefined | Initial selection when modelValue is omitted. When omitted, the first mounted trigger is selected. |
activationMode | 'automatic' | 'manual' | 'automatic' | Automatic selects on focus; manual requires click or Enter/Space on non-button hosts. |
orientation | 'horizontal' | 'vertical' | 'horizontal' | Drives aria-orientation and roving arrow keys. |
dir | 'ltr' | 'rtl' | undefined | undefined | Optional explicit text direction for roving focus within the list. |
GhostTabsList
| Prop | Type | Default | Contract |
|---|---|---|---|
as | GhostTabsListElement | 'div' | Element tag or component for the list. |
GhostTabsTrigger
| Prop | Type | Default | Contract |
|---|---|---|---|
as | GhostTabsTriggerElement | 'button' | Element tag or component (for example GhostButton). |
value | string | required | Stable id matching a GhostTabsContent value. |
disabled | boolean | false | Skips roving focus and prevents selection. Native disabled on <button>; aria-disabled otherwise. |
GhostTabsContent
| Prop | Type | Default | Contract |
|---|---|---|---|
as | GhostTabsContentElement | 'div' | Element tag or component for the panel. |
value | string | required | Must match a trigger value. |
Native attributes and listeners fall through to each part’s rendered root.
v-model contracts
GhostTabs owns modelValue via useControllableState:
- When
modelValueisundefined(omitted), internal state starts atdefaultValuewhen provided; otherwise the first registered trigger value. update:modelValueemits on every user-driven or programmatic selection change while uncontrolled; controlled consumers must apply the emitted value.valuestrings are opaque to the component; consumers must keep trigger/content pairs consistent.
Events, callbacks, slots, and exposed methods
GhostTabsemitsupdate:modelValuewith[value: string].GhostTabsdefault slot receives{ modelValue: string | undefined }.GhostTabsList,GhostTabsTrigger, andGhostTabsContentexpose{ element: HTMLElement | null, focus(), blur() }matching other interactive parts. RenderlessGhostTabsexposeselement: null.
State model
- Selection is a single
modelValuestring matching one trigger/content pair. - Inactive panels use the native
hiddenattribute andtabindex="-1"; the active panel usestabindex="0"for APG panel focus entry. data-state="active" | "inactive"on triggers and panels mirrors selection.
Loading, empty, disabled, read-only, and error states
Only per-tab disabled on GhostTabsTrigger is supported. Disabled tabs are skipped by useRovingFocus and cannot be selected.
Consumer data
GhostTabs does not mutate consumer collections. Tab labels and panel bodies are slot content.
Accessibility contract
Follows WAI-ARIA APG Tabs.
Semantics and relationships
GhostTabsList:role="tablist",aria-orientation,data-part="list", classghost-tabs-list,data-ghost-tabs.GhostTabsTrigger:role="tab",aria-selected,aria-controls→ panel id when registered, deterministicidfromuseGhostId(overridable viaid),data-part="trigger", classghost-tabs-trigger,data-ghost-tabs.GhostTabsContent:role="tabpanel",aria-labelledby→ trigger id when registered, panelidfromuseGhostId,hiddenwhen inactive,data-part="content", classghost-tabs-content,data-ghost-tabs.
Keyboard interaction
Roving among tabs (useRovingFocus on GhostTabsList):
| Key | Orientation | Behavior |
|---|---|---|
ArrowRight | horizontal | Next enabled tab (RTL: previous). |
ArrowLeft | horizontal | Previous enabled tab (RTL: next). |
ArrowDown | vertical | Next enabled tab. |
ArrowUp | vertical | Previous enabled tab. |
Home | either | First enabled tab. |
End | either | Last enabled tab. |
Arrow, Home, and End combined with Alt, Ctrl, or Meta, and keys that belong to an IME composition, are not handled so platform shortcuts keep working.
Activation (GhostTabsTrigger):
| Key | activationMode | Behavior |
|---|---|---|
| Focus | automatic | Selects the focused tab. |
| Click | either | Selects the tab. |
Enter/Space | manual | Selects when as is not a native <button> (buttons use native click). |
Disabled tabs are skipped by roving focus and cannot be activated.
Focus behavior
- The selected enabled tab is the sequential tab stop (
tabindex="0"); other enabled tabs usetabindex="-1", including native<button>hosts (so the initial stop is not always the first tab). - Arrow keys move focus among tabs via
useRovingFocus; in automatic mode, focus activation also updates selection. When focus leaves the tab list, tab stops reset to the selected tab so a laterTabinto the list focuses the active tab, not the last arrow-focused tab in manual mode. - If the selected value is missing or its trigger is disabled, the tab stop falls back to the first enabled trigger without changing
modelValue. - Tab out of the list moves to the next document tab stop; the visible
tabpanelusestabindex="0". Focus does not trap inside panels.
Assistive technology expectations
Screen readers announce the tab list, selected tab, and associated panel via aria-selected, aria-controls, and aria-labelledby.
Rendering and customization
Stable hooks (not the undecided GHO-38 styling-hooks contract):
ghost-tabs-list,ghost-tabs-trigger,ghost-tabs-contentclassesdata-part,data-state,data-ghost-tabs- Consumer
classandstyleon the list, trigger, and content parts merge with the part class and never replace it - Themed CSS under
.ghost-theme/.ghost-themed-scopeusing existing--ghost-*semantic tokens
Environment behavior
SSR and hydration
useGhostIdsupplies deterministic SSR-safe ids.useRovingFocusattaches listeners only inonMounted(nodocumentaccess during SSR setup).- Panels remain in the DOM with
hiddenwhen inactive so relationships hydrate.
Mobile and touch
Pointer activation on triggers selects tabs; no separate gesture model.
Performance
Global listeners are limited to roving keydown/focusin on the tab list element while mounted.
Composition
useGhostTabs+useControllableStatefor selection.useGhostIdper trigger and panel.useRovingFocusonGhostTabsList.
Test plan
- Unit (
GhostTabs.test.ts): horizontal/vertical arrows, RTL horizontal, Home/End, manual Enter/Space, disabled skip,aria-controls/aria-labelledby, SSR without roving listeners, controlled/uncontrolled selection. - Browser (
ghost-tabs.spec.ts): example gallery keyboard/pointer, Axe zero violations,@component:GhostTabs. - Cross-browser (
rtl-roving.spec.ts,@cross-browser): RTL layout order, mirrored arrows with real focus andaria-selected, Home/End, in Chromium, Firefox, and WebKit. No engine differences found; focus and ARIA assertions are shared. - Themed integration: themed root ref reaches list element.
- Type tests: optional consumer fixtures when exports stabilize.
Documentation plan
docs/components/tabs.mdwith headless and themed examples.- Registry entries for
tabs/basic,tabs/manual,tabs/vertical,tabs/themed. - Playground
TabsReferencesection with unique copy. - Manifests via
pnpm manifests:write.
Compatibility and release impact
Additive minor Changeset for @ghostvue/vue and @ghostvue/themes.
Open architectural questions
None.
Control size amendment
Important
Approved 2026-12-03 by @zprue743. This amendment adds a size prop to the themed GhostTabsList. The contract decision records the chosen options. Target release: 0.4.0.
Why a size option
Themed triggers are one medium control tall (control.size.md.min). A tab strip in a toolbar or compact header beside size="sm" buttons and inputs is taller than its neighbours, and there is no supported way to match them.
The same gap exists on GhostSegmentedControl, GhostToggleGroup and GhostSelectTrigger. Each spec carries a matching amendment, so all four follow GhostButton and GhostInput, which already take size: 'sm' | 'md' | 'lg'.
Public API
Themed GhostTabsList in @ghostvue/themes only:
| Prop | Type | Default | Contract |
|---|---|---|---|
size | 'sm' | 'md' | 'lg' | 'md' | Every trigger in the list takes height, label size and padding from control.size.<size>, matching a GhostButton or GhostInput of the same size. |
- The union is exported as
GhostTabsListSize, followingGhostButtonSizeandGhostInputSize. - The wrapper renders
data-size="sm"ordata-size="lg"on the list and omits it formd, asGhostButtonandGhostInputdo. The wrapper consumessize, so it never reaches the DOM as asizeattribute. data-sizeon the list is the styling hook. A headlessGhostTabsListinside.ghost-themethat setsdata-sizeitself gets the same sizing, as withGhostButton.GhostTabsTriggerandGhostTabsContenttake nosize. Panels keep their current padding at every size.- Headless
@ghostvue/vuedoes not change: no prop, type or manifest change.
GhostTabs is renderless, so it has no element for data-size. Putting size on the list keeps the hook on a real element and needs no new provide/inject.
Sizing contract
For each size, S below means control.size.<size>.
- Height. Each trigger has
min-block-size: S.min, so it matches aGhostInputorGhostButtonwith the samesizein the same density. The list has no track or border of its own, so the trigger height is the strip height. - Label and padding. Font size is
S.font; block and inline padding areS.padding.blockandS.padding.inline. The gap between triggers does not change. - Tokens only. No recipe sets its own height, padding or pixel value. Densities change
S.*and the control follows. - Coarse pointers. The generated tokens set
sm,mdandlgto the same 44px minimum under(pointer: coarse)in every density, sosmnever shrinks a touch target. - Device scale factor 2. Triggers have no subtracted minimum, so the hairline rounding seen on the segmented control does not apply. The parity case still runs at 2x.
Accessibility
Roles, names, states, keyboard and focus do not change. The trigger is the activation target and carries the full control height, so sm in compact density (28px) stays above the 24px WCAG 2.2 target-size minimum (2.5.8). Coarse pointers keep the 44px minimum.
Implementation acceptance cases
- Size parity (browser). A playground fixture renders one row per density (
compact,comfortable,spacious). Each row holdsGhostButton,GhostInputand a horizontalGhostTabsListatsm,mdandlg. At every size and density, each trigger's border-box block size equals theGhostInputof the same size (difference under 0.5px). One fixture serves all four amended components. - Device scale factor 2. The parity comparison also runs in Chromium at
deviceScaleFactor: 2. - Vertical. A vertical list at
smgives every trigger thesmminimum height. - Default unchanged. Omitting
sizerenders nodata-size. Thetabs/themedexample renders as it does today. - Coarse pointer. With
isMobileandhasTouch, every activation target is at least 44px tall at every size. - Wrapper (unit).
size="sm"andsize="lg"render the matchingdata-size;mdand an omittedsizerender none. Nosizeattribute reaches the DOM. A type test rejectssize="xl"onGhostTabsList. - Manifests and API tables. A themed
GhostTabsListmanifest,packages/themes/manifests/ghost-tabs-list.manifest.json, records the prop (asghost-tabs-content.manifest.jsondoes for the panel variant), andpnpm docs:api:writeupdates the generated API table.
Documentation plan
- A Size section in
docs/components/tabs.mdwith one runnable example showing a tab strip atsize="sm"beside a smallGhostButtonandGhostInput. - Generated API tables and the themed manifest list the prop.
- A
@ghostvue/themesChangeset.
Compatibility
Additive. The default stays md. A size attribute passed to the themed list today falls through to its root element and has no effect; after the change it is a typed prop. Minor Changeset for @ghostvue/themes.
Contract decision
Recorded 2026-12-03. @zprue743 took the recommended option for each question, and Q1, Q2 and Q4 have the same answer in all four amended specs. Each question lists the chosen option first and the rejected alternative after it.
- Q1 — Where
sizelives. Chosen: onGhostTabsList, sinceGhostTabsis renderless and the list is the strip that sits in a toolbar. Rejected: onGhostTabs, passed to the list and triggers through injection. - Q2 — Themed only. Chosen:
sizebelongs to the themed wrappers, as forGhostButtonandGhostInput. Headless components stay unstyled anddata-sizeis the styling hook. Rejected: addsizeto the headless props as a data attribute only. - Q3 — Panels. Chosen:
sizechanges triggers only and leavesGhostTabsContentpadding alone. Rejected: scale panel padding with the list size. - Q4 — Release and delivery. Chosen:
0.4.0, with all four components in one implementation change so they share the parity fixture. Rejected: one change per component, in the order segmented control, toggle group, select trigger, tabs.
Content variant amendment
Important
Maintainer decision recorded 2026-12-01; spec amendment approved by @zprue743 on 2026-12-03. Themed GhostCollapsibleContent and GhostTabsContent take the same variant prop with the same values. This section records it for GhostTabsContent; the collapsible spec carries the matching amendment.
Why a variant
The themed panel draws an elevation-1 background, a hairline border, a large corner radius, and inset padding. Placed inside another framed surface, such as a GhostCard or a code block, the panel draws a second border and inset padding inside the first. There is no supported way to turn that frame off.
Public API
Themed GhostTabsContent in @ghostvue/themes only:
| Prop | Type | Default | Contract |
|---|---|---|---|
variant | 'framed' | 'plain' | 'framed' | framed is today's panel. plain removes the panel's border, corner radius, background and padding. |
- The union is exported as
GhostTabsContentVariant, followingGhostInlineAlertVariantandGhostBadgeVariant. - The wrapper renders
data-variant="plain"on the panel and omitsdata-variantforframed, asGhostInlineAlertandGhostBadgeomit their default. The wrapper consumesvariant, so it never reaches the DOM as avariantattribute. data-variant="plain"on theghost-tabs-contentpanel is the styling hook, under the same.ghost-theme,.ghost-themed-scope, or[data-themed]scopes as the framed recipe.- Headless
@ghostvue/vuedoes not change: no prop, type, or manifest change.GhostTabs,GhostTabsList, andGhostTabsTriggertake novariant. Accordion content is out of scope.
Styling contract
- Removed by
plain: border, border radius, background, and padding on the panel. - Kept: text color and type, the top margin that separates the panel from the tab strip, and the
:focus-visibleoutline ring. Tabs, the strip, anddata-stateare unchanged. - Tokens only. The plain rules reset properties to
0ortransparentand add no literal sizes or colors.
Accessibility and motion
Roles, names, states, keyboard, and focus order do not change. The active panel stays a tab stop (tabindex="0") and draws the same :focus-visible ring as the framed panel. Tabs have no panel motion, so there is no motion change.
Implementation acceptance cases
- Wrapper (integration). Omitting
variantandvariant="framed"render nodata-variant;variant="plain"rendersdata-variant="plain"; novariantattribute reaches the DOM. - Computed styles (browser). In a themed host, the active plain panel has zero border width, zero radius, a transparent background, and zero padding, and draws the focus ring when reached with
Tab; a framed panel keeps its frame. - Example and baseline.
tabs/install-commandsshows the plain panel inside aGhostCardand has visual baselines in light and dark. - Manifests and API tables. The themed manifest
packages/themes/manifests/ghost-tabs-content.manifest.jsonrecords the prop, andpnpm docs:api:writeupdates the table ondocs/components/tabs.md.
Compatibility
Additive. The default stays framed, so existing panels render as before. A variant attribute passed to the themed panel today falls through to the DOM and has no effect; after the change it is a typed prop. Minor Changeset for @ghostvue/themes.