Skip to content

GhostTabs specification ​

Status: Proposed for GHO-29. Spec and implementation ship together; Zac approves both in PR review.

Amendment (approved 2026-12-03): a variant prop on the themed GhostTabsContent is recorded in the Content variant amendment. The maintainer @zprue743 approved it in PR review on 2026-12-03.

Amendment (approved 2026-12-03): a size prop on the themed GhostTabsList is 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 via default.css)

Props and configuration ​

GhostTabs (root) ​

PropTypeDefaultContract
modelValuestring | undefinedundefinedControlled selected tab value. Omit for uncontrolled mode.
defaultValuestring | undefinedundefinedInitial 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' | undefinedundefinedOptional explicit text direction for roving focus within the list.

GhostTabsList ​

PropTypeDefaultContract
asGhostTabsListElement'div'Element tag or component for the list.

GhostTabsTrigger ​

PropTypeDefaultContract
asGhostTabsTriggerElement'button'Element tag or component (for example GhostButton).
valuestringrequiredStable id matching a GhostTabsContent value.
disabledbooleanfalseSkips roving focus and prevents selection. Native disabled on <button>; aria-disabled otherwise.

GhostTabsContent ​

PropTypeDefaultContract
asGhostTabsContentElement'div'Element tag or component for the panel.
valuestringrequiredMust 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 modelValue is undefined (omitted), internal state starts at defaultValue when provided; otherwise the first registered trigger value.
  • update:modelValue emits on every user-driven or programmatic selection change while uncontrolled; controlled consumers must apply the emitted value.
  • value strings are opaque to the component; consumers must keep trigger/content pairs consistent.

Events, callbacks, slots, and exposed methods ​

  • GhostTabs emits update:modelValue with [value: string].
  • GhostTabs default slot receives { modelValue: string | undefined }.
  • GhostTabsList, GhostTabsTrigger, and GhostTabsContent expose { element: HTMLElement | null, focus(), blur() } matching other interactive parts. Renderless GhostTabs exposes element: null.

State model ​

  • Selection is a single modelValue string matching one trigger/content pair.
  • Inactive panels use the native hidden attribute and tabindex="-1"; the active panel uses tabindex="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", class ghost-tabs-list, data-ghost-tabs.
  • GhostTabsTrigger: role="tab", aria-selected, aria-controls → panel id when registered, deterministic id from useGhostId (overridable via id), data-part="trigger", class ghost-tabs-trigger, data-ghost-tabs.
  • GhostTabsContent: role="tabpanel", aria-labelledby → trigger id when registered, panel id from useGhostId, hidden when inactive, data-part="content", class ghost-tabs-content, data-ghost-tabs.

Keyboard interaction ​

Roving among tabs (useRovingFocus on GhostTabsList):

KeyOrientationBehavior
ArrowRighthorizontalNext enabled tab (RTL: previous).
ArrowLefthorizontalPrevious enabled tab (RTL: next).
ArrowDownverticalNext enabled tab.
ArrowUpverticalPrevious enabled tab.
HomeeitherFirst enabled tab.
EndeitherLast 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):

KeyactivationModeBehavior
FocusautomaticSelects the focused tab.
ClickeitherSelects the tab.
Enter/SpacemanualSelects 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 use tabindex="-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 later Tab into 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 tabpanel uses tabindex="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-content classes
  • data-part, data-state, data-ghost-tabs
  • Consumer class and style on the list, trigger, and content parts merge with the part class and never replace it
  • Themed CSS under .ghost-theme / .ghost-themed-scope using existing --ghost-* semantic tokens

Environment behavior ​

SSR and hydration ​

  • useGhostId supplies deterministic SSR-safe ids.
  • useRovingFocus attaches listeners only in onMounted (no document access during SSR setup).
  • Panels remain in the DOM with hidden when 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 + useControllableState for selection.
  • useGhostId per trigger and panel.
  • useRovingFocus on GhostTabsList.

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 and aria-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.md with headless and themed examples.
  • Registry entries for tabs/basic, tabs/manual, tabs/vertical, tabs/themed.
  • Playground TabsReference section 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:

PropTypeDefaultContract
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, following GhostButtonSize and GhostInputSize.
  • The wrapper renders data-size="sm" or data-size="lg" on the list and omits it for md, as GhostButton and GhostInput do. The wrapper consumes size, so it never reaches the DOM as a size attribute.
  • data-size on the list is the styling hook. A headless GhostTabsList inside .ghost-theme that sets data-size itself gets the same sizing, as with GhostButton.
  • GhostTabsTrigger and GhostTabsContent take no size. Panels keep their current padding at every size.
  • Headless @ghostvue/vue does 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 a GhostInput or GhostButton with the same size in 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 are S.padding.block and S.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, md and lg to the same 44px minimum under (pointer: coarse) in every density, so sm never 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 ​

  1. Size parity (browser). A playground fixture renders one row per density (compact, comfortable, spacious). Each row holds GhostButton, GhostInput and a horizontal GhostTabsList at sm, md and lg. At every size and density, each trigger's border-box block size equals the GhostInput of the same size (difference under 0.5px). One fixture serves all four amended components.
  2. Device scale factor 2. The parity comparison also runs in Chromium at deviceScaleFactor: 2.
  3. Vertical. A vertical list at sm gives every trigger the sm minimum height.
  4. Default unchanged. Omitting size renders no data-size. The tabs/themed example renders as it does today.
  5. Coarse pointer. With isMobile and hasTouch, every activation target is at least 44px tall at every size.
  6. Wrapper (unit). size="sm" and size="lg" render the matching data-size; md and an omitted size render none. No size attribute reaches the DOM. A type test rejects size="xl" on GhostTabsList.
  7. Manifests and API tables. A themed GhostTabsList manifest, packages/themes/manifests/ghost-tabs-list.manifest.json, records the prop (as ghost-tabs-content.manifest.json does for the panel variant), and pnpm docs:api:write updates the generated API table.

Documentation plan ​

  • A Size section in docs/components/tabs.md with one runnable example showing a tab strip at size="sm" beside a small GhostButton and GhostInput.
  • Generated API tables and the themed manifest list the prop.
  • A @ghostvue/themes Changeset.

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.

  1. Q1 — Where size lives. Chosen: on GhostTabsList, since GhostTabs is renderless and the list is the strip that sits in a toolbar. Rejected: on GhostTabs, passed to the list and triggers through injection.
  2. Q2 — Themed only. Chosen: size belongs to the themed wrappers, as for GhostButton and GhostInput. Headless components stay unstyled and data-size is the styling hook. Rejected: add size to the headless props as a data attribute only.
  3. Q3 — Panels. Chosen: size changes triggers only and leaves GhostTabsContent padding alone. Rejected: scale panel padding with the list size.
  4. 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:

PropTypeDefaultContract
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, following GhostInlineAlertVariant and GhostBadgeVariant.
  • The wrapper renders data-variant="plain" on the panel and omits data-variant for framed, as GhostInlineAlert and GhostBadge omit their default. The wrapper consumes variant, so it never reaches the DOM as a variant attribute.
  • data-variant="plain" on the ghost-tabs-content panel is the styling hook, under the same .ghost-theme, .ghost-themed-scope, or [data-themed] scopes as the framed recipe.
  • Headless @ghostvue/vue does not change: no prop, type, or manifest change. GhostTabs, GhostTabsList, and GhostTabsTrigger take no variant. 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-visible outline ring. Tabs, the strip, and data-state are unchanged.
  • Tokens only. The plain rules reset properties to 0 or transparent and 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 ​

  1. Wrapper (integration). Omitting variant and variant="framed" render no data-variant; variant="plain" renders data-variant="plain"; no variant attribute reaches the DOM.
  2. 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.
  3. Example and baseline. tabs/install-commands shows the plain panel inside a GhostCard and has visual baselines in light and dark.
  4. Manifests and API tables. The themed manifest packages/themes/manifests/ghost-tabs-content.manifest.json records the prop, and pnpm docs:api:write updates the table on docs/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.