Overlays

Dropdown Menu

A list of actions behind a trigger. Composable parts, real focus management, typeahead and nested submenus.

Installation #

With the Nuxt module, every component is auto-imported — there is nothing to add. In a plain Vue project, import what you use:

Copy
import { JDropdownMenu, JDropdownMenuItem, JDropdownMenuSeparator, JDropdownMenuLabel, JDropdownMenuSub } from '@juxtui/ui'

Usage #

Copy
<JDropdownMenu>
  <template #trigger>
    <JButton variant="outline">Options</JButton>
  </template>
  <JDropdownMenuItem shortcut="⌘E" @select="edit">Edit</JDropdownMenuItem>
  <JDropdownMenuItem @select="duplicate">Duplicate</JDropdownMenuItem>
  <JDropdownMenuSeparator />
  <JDropdownMenuItem destructive @select="remove">Delete</JDropdownMenuItem>
</JDropdownMenu>

The trigger slot takes your own element — attributes and listeners are merged onto it, no wrapper element is added.

Items close the menu when selected. Call event.preventDefault() in @select to keep it open.

Variants & examples #

Hover with a short intent delay, or use → and ←.

Render items as links with as.

API #

JDropdownMenu

PropTypeDefault Description
openbooleanfalseOptionally bound with v-model:open.
placementPlacement'bottom-start'Preferred side and alignment. Flips when there isn’t room.
offsetnumber6Distance from the trigger in px.
disabledbooleanfalsePrevent opening.

Slots

SlotProps Description
trigger{ open }The element that opens the menu.
default—Items, labels, separators and submenus.

JDropdownMenuItem

PropTypeDefault Description
disabledbooleanfalseSkipped by keyboard navigation and not selectable.
destructivebooleanfalseStyles a dangerous action.
shortcutstring—Shortcut hint shown on the right. Display only.
asstring | Component'div'Render as a link or router link.
checkedboolean—Turns the item into one choice of a set (menuitemradio). true shows a check at the end of the row.

Events

EventPayload Description
selectEventThe item was chosen. Cancelable.

Slots

SlotProps Description
default—Label.
leading—Icon.

JDropdownMenuSub

PropTypeDefault Description
labelstring—Label of the item that opens the submenu.
disabledbooleanfalsePrevent opening.

Slots

SlotProps Description
default—Items of the submenu.
leading—Icon.

JDropdownMenuLabel · JDropdownMenuSeparator

Slots

SlotProps Description
default—Label text (label only).

Accessibility #

  • Follows the WAI-ARIA menu button pattern: the trigger gets aria-haspopup, aria-expanded and aria-controls.
  • Hovering moves real focus to the item, so the pointer and the keyboard always agree on a single highlighted item.
  • Submenu triggers expose aria-haspopup="menu" and aria-expanded.
  • When the menu closes after a selection or Escape, focus returns to the trigger.

Keyboard #

Key Action
EnterOn the trigger: open and focus the first item. On an item: select it.
SpaceSame as Enter.
↓↑Move between items, wrapping around. On the trigger, opens on the first or last item.
HomeEndFirst or last item.
→Open a submenu and focus its first item.
←Close a submenu and return to its parent item.
A–ZTypeahead to the next matching item.
EscClose the current menu and return focus.
TabClose the menu.