Skip to content

Menu

Open a menu of actions from a button.

Demos

Size

Usage

vue
<script setup lang="ts">
import { Accordion } from '~/components/ui/accordion'

const items = [
  { value: 'source', label: 'Do I own the source?', content: 'Yes. Copy and adapt the files.' },
]
</script>

<template>
  <Accordion :items="items" />
</template>

Installation

Complete the shared installation. Copy Menu.vue and index.ts into app/components/ui/menu/.

API

Variants and defaults

PropValuesDefault
sizexs, sm, md, lg, xlsm

Props

PropTypeDefaultDescription
itemsMenuItem[] | MenuItem[][]—Flat array or grouped array (groups get auto-separators).
side"top" | "bottom" | "left" | "right""bottom"Preferred side to position the menu.
align"start" | "center" | "end""start"Alignment relative to the trigger.
sideOffsetnumber4Gap in px between trigger and menu.
closeOnSelectbooleantrueClose the menu after an item is selected.
radioValuesRecord<string, string>—v-model:radio-values — state for radio groups.
teleportstring | falsefalseTeleport target for the menu.
asstring | Component"div"Root element tag.
dir"ltr" | "rtl""ltr"Logical keyboard direction and preferred submenu side.
uiMenuUi—CSS class overrides.

Slots

SlotScoped propsDescription
trigger{ isOpen, open, close, toggle, triggerProps }The element that opens the menu.
[item.slot]{ item }Per-item render override when item.slot is set.

Events

EventPayloadDescription
open-change[open: boolean, details]Fired when the open state changes.
select[item: MenuItem, details]Fired when an item is selected.
check-change[item: MenuItem, checked: boolean, details]Fired when a checkbox item changes.
radio-change[group: string, value: string, details]Fired when a radio item is selected.
update:radioValues[values: Record<string, string>]v-model event for radio group state.

Exposed methods

MethodSignatureDescription
open(reason?, event?) => voidOpens the menu.
close(reason?, event?) => voidCloses the menu.
toggle(reason?, event?) => voidToggles the menu.

Keyboard

KeyBehavior
ArrowDown / ArrowUpMoves focus through enabled items and loops.
Home / EndFocuses first or last enabled item.
Enter / SpaceActivates item, checkbox, radio, or opens submenu.
ArrowRightOpens focused submenu and moves into it; reversed in RTL.
ArrowLeftCloses submenu and restores submenu-trigger focus; reversed in RTL.
EscapeCloses submenu level or whole menu.
Printable charactersTypeahead focuses first matching item within 500 ms buffer.

Opening with a pointer focuses the menu panel without highlighting an item. Arrow keys then move through items. Keyboard activation focuses the first enabled item. Trigger keyboard activation comes from trigger element supplied by user; apply triggerProps and use a native button.