Skip to content

GhostMenubar ​

GhostMenubar implements the WAI-ARIA APG Menubar pattern (GHO-107): a horizontal role="menubar" with one tab stop, roving focus among top-level menuitem triggers, and action menus that can contain nested commands.

Import the parts from @ghostvue/themes for default elevation and item styling. To style the bar and menus yourself, see Advanced: headless composition.

Run editor commands ​

Editor commands

Create, duplicate, or export a document from a File, Edit, and View menubar; the document name and status line show each command.

release-notes.md Use ArrowLeft / ArrowRight across menus, ArrowDown to open.
Ready — Word wrap on · Line numbers on · Comfortable layout

Every part in this example comes from @ghostvue/themes. The editor toolbar composes GhostMenubarTrigger with :as="GhostButton" and keeps a single Tab stop across File, Edit, and View. Press Tab to reach File, then ArrowDown, Enter, or Space to open it with focus on New draft. Press Enter to run it: the document name changes to Untitled draft.md, the role="status" footer records the command, and focus returns to File. Duplicate names a copy of the open document in the same way. Checkbox and radio items under View toggle without leaving the menu. Themed content sets data-themed on portaled panels so .ghost-menubar-content picks up elevation-3 tokens and item hover and focus styles in light and dark mode.

Checkbox item model

GhostMenubarCheckboxItem binds its state with v-model:checked or plain v-model. Both names stay in sync; if you bind both, checked decides what the item shows.

Nested commands ​

Open File → Export → Text formats → Markdown to export the document. The forward arrow on Export opens its child. The same arrow on PDF switches to Edit and focuses its first command. Back closes the current child, or switches to the previous top-level menu from root content. Forward is Right in LTR and Left in RTL. Escape returns one level at a time, and Tab or Shift+Tab leaves the entire menubar from any depth.

Advanced: headless composition ​

Teams that bring their own design system can import the same parts from @ghostvue/vue. They keep the menubar behavior and paint nothing, so the example brings its own consumer CSS for the bar, panels, and item states.

Basic use ​

Basic Headless

Headless menubar with items, checkbox, radio group, label, separator, and disabled item.

GhostMenubar registers each GhostMenubarMenu, enforces at most one open menu, and delegates horizontal trigger navigation to useRovingFocus. Each menu reuses useGhostMenubarMenu (overlay stack + useGhostMenuCollection for item keyboard behavior).

API ​

See the generated component references for props, emits, slots, exposed members, styling hooks, and executable examples.

PropTypeDefaultDescription
asComponent | string"div"Declared prop as.
dir'ltr' | 'rtl'—Declared prop dir.
SlotSlot propsDescription
default—Container content.

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

Composition ​

  • GhostMenubar — role="menubar" container; optional dir for RTL arrow flip.
  • GhostMenubarMenu — renderless open state (v-model:open).
  • GhostMenubarTrigger — role="menuitem" with aria-haspopup="menu".
  • GhostMenubarContent — floating role="menu" (default placement="bottom-start").
  • Item, group, label, separator, checkbox, and radio parts match GhostDropdownMenu semantics inside each menu.

Place GhostSubmenu in the menu content and use the usual GhostMenubarItem, checkbox, and radio parts for its commands. Shared submenu API

See GhostMenubar specification for the full accessibility contract and keyboard table.