Skip to content

GhostDropdownMenu ​

GhostDropdownMenu is the floating actions menu for GHO-80 (WAI-ARIA APG Menu Button semantics, not dialog, tooltip, or native <select>).

Import the parts from @ghostvue/themes for the elevated menu surface and interactive item styling. Every preview before the advanced section uses those themed parts. To style the menu yourself, see Advanced: headless composition, which shows the headless @ghostvue/vue parts.

Record actions ​

Record actions

Brief list with a per-row actions menu: grouped edit, duplicate, and status items, a destructive Archive with undo, and focus that follows each outcome.

Launch briefs

3 active · 1 published

  • Spring launch briefMaya Chen · Updated Nov 12
    Published
  • Pricing page refreshJonas Weber · Updated Nov 14
    Draft
  • Onboarding email seriesPriya Natarajan · Updated Nov 18
    Draft

Every part in this example comes from @ghostvue/themes. Focus a row's Actions button and press Enter, Space, or ArrowDown to open its menu on the first item (ArrowUp opens it on the last). Move with the arrow keys and press Enter to run a command.

Each brief has an icon-only Actions trigger whose accessible name includes the brief title. The menu groups Edit title and Duplicate, then the status action, and sets Archive apart after a separator in the danger text color. Every action changes the list and is announced in the role="status" line. Focus follows the outcome: Edit title moves focus to the title field, Save, Cancel, and Escape return it to the row's trigger, and Archive moves it to the next row's trigger (or Undo archive when the list is empty) because the trigger that opened the menu has gone. The panel opens at bottom-end under the trigger; flip and shift keep it inside the viewport when a row sits near the bottom or the inline edge. Below about 22rem the status badge moves under the title so the trigger stays on the row. The menu surface is fully opaque from the first frame so Archive keeps its contrast while the panel opens. It scales into place with normal motion and opens immediately when reduced motion is requested.

Nested actions ​

Report export actions

Open a portaled submenu to choose an export format and include report notes.

Choose a format to export this report.

Place GhostSubmenu inside the menu content and give GhostSubmenuTrigger a visible label. The child uses ordinary dropdown items, including toggleable checkboxes and radio items. Use portal on GhostSubmenuContent when an ancestor would clip the child. The accessible name and focus behavior still follow the trigger with a custom portalTo.

Enter, Space, or the inline-end arrow opens a child and focuses its first enabled item. The inline-start arrow or Escape closes that level and returns focus to its trigger. Tab and Shift+Tab close the branch and continue from the dropdown button. The arrows reverse in RTL.

Bind v-model:open on GhostSubmenu to control visibility. If a controlled child declines to close, opening a sibling leaves that branch in place.

GhostSubmenu ​

PropTypeDefaultDescription
defaultOpenbooleanfalseInitially opens the child in uncontrolled mode.
openboolean—Controlled request for the child to open.
SlotSlot propsDescription
default—Primary content.

GhostSubmenuTrigger ​

PropTypeDefaultDescription
disabledbooleanfalseExcludes this trigger from roving focus, typeahead, and activation.
SlotSlot propsDescription
default—Primary content.

GhostSubmenuContent ​

PropTypeDefaultDescription
portalbooleanfalseRenders the child via a Vue teleport.
portalToGhostPortalTarget"body"Destination for a portaled child menu.
SlotSlot propsDescription
default—Primary content.

View options ​

View options

Inbox toolbar view menu with checkbox and radio items, visible check indicators, and a reset action on the elevation-3 surface.

InboxNewest first · unread on top · previews on

The inbox View menu changes how the list above it reads. It labels its checkbox group and radio group with GhostDropdownMenuLabel through aria-labelledby. Checkbox items toggle without closing, and the summary line updates as you go. Choosing a sort order or Reset view closes the menu and returns focus to View. The theme does not draw a check mark, so the example renders its own aria-hidden indicator in a fixed-width slot; aria-checked carries the state for assistive technology.

Checkbox item model

GhostDropdownMenuCheckboxItem 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.

Importing from @ghostvue/themes loads default.css, styling .ghost-dropdown-menu-content with elevation-3 surface tokens and [data-part="item"], checkbox, radio, label, and separator hooks inside the panel. The themed GhostDropdownMenuContent sets data-themed so portaled menus pick up tokens outside a .ghost-theme host.

Advanced: headless composition ​

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

Basic use ​

Basic Headless

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

The headless GhostDropdownMenu owns open via useControllableState, assigns deterministic IDs via useGhostId, positions the panel with useFloating, renders through GhostPortal by default, unmounts content with v-if when closed, closes on Escape and outside pointerdown through useDismissableLayer, restores focus to the trigger on close via useFocusScope, and delegates item roving, typeahead, and activation keys to useGhostMenuCollection.

API ​

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

PropTypeDefaultDescription
defaultOpenbooleanfalseDeclared prop defaultOpen.
openboolean—Declared prop open.
SlotSlot propsDescription
defaultclose: () => void, open: booleanPrimary content.

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

GhostDropdownMenu (root) ​

Emits update:open with (open: boolean). The default slot receives { open: boolean, close: () => void }.

GhostDropdownMenuTrigger ​

Sets type="button" (when as="button"), aria-haspopup="menu", aria-expanded, aria-controls, data-part="trigger", and data-state="open" | "closed". ArrowDown / ArrowUp opens the menu and focuses the first or last item. Exposes { element, focus, blur }.

GhostDropdownMenuContent ​

Keeps visibility: hidden until useFloating().isPositioned resolves. Sets role="menu", tabindex="-1", data-part="content", and data-state. Exposes { element, focus, blur }.

Items and groups ​

  • GhostDropdownMenuItem — role="menuitem"; emits select with the activating event. The menu closes unless the handler calls event.preventDefault().
  • GhostDropdownMenuCheckboxItem — role="menuitemcheckbox" with v-model:checked or plain v-model; toggles without closing.
  • GhostDropdownMenuRadioGroup / GhostDropdownMenuRadioItem — menuitemradio collection with v-model; selecting a radio emits (value, event) and closes unless event.preventDefault().
  • GhostDropdownMenuLabel, GhostDropdownMenuSeparator, GhostDropdownMenuGroup — structural parts with data-part hooks only (no roving focus).

Accessibility ​

  • Menu semantics: Trigger advertises aria-haspopup="menu"; content uses role="menu" with roving tabindex="-1" items (not a dialog or listbox).
  • Keyboard: Arrow keys move among enabled items; Home / End jump; typeahead focuses the next match; Enter / Space activate; checkbox items toggle on Space without dismissing; Escape closes and returns focus to the trigger. Keys owned by an active IME composition are left to the input method.
  • Dismissal: Outside pointer and Escape use useDismissableLayer with the trigger ignored so trigger clicks toggle cleanly.

Specification ​

See GhostDropdownMenu specification and ADR 0011.