Skip to content

shadcn.io is an independent project built on shadcn/ui

Components

Free

Dropdown Menu for Vue

A Vue dropdown menu on Ark UI: a button opens a list of actions, with submenus, checkbox and radio rows, and shortcut hints.

On this page9 sections
UI library: Ark UI

A dropdown menu is a list of actions that opens from a button: the ellipsis at the end of a table row, the avatar in an app header, a More button in a toolbar. Choosing an item runs it and closes the list. Rows can also open a submenu, or carry a checkbox or radio mark for a view setting.

For a value that a form submits, use a Select. A menu that opens with a right-click on an area of the page is a Context Menu.

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

Anatomy

Dropdown Menu anatomy: trigger, label, item, shortcut, separator, sub trigger, content

Usage

<script setup lang="ts">
import { Button } from "@/components/ui/button";
import {
  DropdownMenu, DropdownMenuContent, DropdownMenuGroup,
  DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator,
  DropdownMenuShortcut, DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu";
</script>

Each DropdownMenuItem needs a value, which is how the menu tells your select handler which item was chosen.

<DropdownMenu positioning={{ placement: "bottom-start" }}>
  <DropdownMenuTrigger asChild>
    <Button variant="outline">Open</Button>
  </DropdownMenuTrigger>
  <DropdownMenuContent className="w-40">
    <DropdownMenuGroup>
      <DropdownMenuLabel>My Account</DropdownMenuLabel>
      <DropdownMenuItem value="profile">Profile</DropdownMenuItem>
      <DropdownMenuItem value="billing">Billing</DropdownMenuItem>
      <DropdownMenuItem value="settings">
        Settings
        <DropdownMenuShortcut>⌘S</DropdownMenuShortcut>
      </DropdownMenuItem>
    </DropdownMenuGroup>
    <DropdownMenuSeparator />
    <DropdownMenuItem value="logout">Log out</DropdownMenuItem>
  </DropdownMenuContent>
</DropdownMenu>

Accessibility

The trigger is a button with aria-haspopup="menu" and aria-expanded, and the list is a role="menu" labelled by the trigger. Focus stays on the list while the arrow keys move a highlight that aria-activedescendant reports, typing a letter jumps to the next item that starts with it, and checkbox and radio rows report aria-checked. Choosing an item or pressing Escape returns focus to the trigger. Give an icon-only trigger an aria-label, as the ellipsis in the Actions demo has.

Space
Activates/Selects the highlighted item.
Enter
Activates/Selects the highlighted item.
Arrow Down
Highlights the next item in the menu.
Arrow Up
Highlights the previous item in the menu.
Arrow Right
When focus is on trigger, opens or closes the submenu depending on reading direction.
Arrow Left
When focus is on trigger, opens or closes the submenu depending on reading direction.
Escape
Closes the menu and moves focus to the trigger.
Home
Highlights the first item in the menu.
End
Highlights the last item in the menu.

Demos

Basic

Profile, Billing and Settings under a My Account label, then a separator, GitHub, Support and a disabled API row. Start here for a short account menu. The label names the group but isn't an item, so it can't be chosen and the arrow keys pass over it, while the disabled row stays in view for something people can't use yet.

Preview width

Invite users opens a second panel with Email and Message, and More options inside it opens a third with Calendly, Slack and Webhook. Reach for a submenu when a few related actions would crowd the first list. Keep to two levels where you can, since every extra panel is one more hover path to hold and one more key press back out.

Preview width

Shortcuts

Profile, Billing, Settings and Log out each end in a key hint, such as ⇧⌘P. DropdownMenuShortcut is a styled span: it prints the hint and listens for nothing. Bind the keys yourself at the page level, where they work while the menu is closed, and only show a hint for a shortcut that exists.

Preview width

Icons

A person, a card and a gear in front of Profile, Billing and Settings, and a destructive Log out below a separator. Each icon has aria-hidden, because the label already names the action and a screen reader shouldn't read it twice. Add icons to a menu people open often, where a familiar picture is quicker to find than a word.

Preview width

Checkboxes

An Appearance group where Status Bar starts checked, Activity Bar is disabled and Panel starts off. The demo listens with @checked-change, which the Ark UI checkbox item never emits, so a click closes the menu and the mark doesn't move. Bind v-model:checked on each row for a toggle that sticks.

Preview width

Checkboxes icons

A Notifications button opens email, SMS and push channels, each with its own icon, and email and push start on. Here the icons earn their place: three channels with similar labels are easier to tell apart at a glance in a narrow menu. The check mark sits at the end of the row, so it never competes with the icon at the start.

Preview width

Radio group

Panel Position offers Top, Bottom and Right, with Bottom chosen. The demo listens with @value-change, which the Ark UI radio group never emits, so a click closes the menu and the mark stays on Bottom. Bind v-model on DropdownMenuRadioGroup to hold the chosen value.

Preview width

Radio icons

A Payment Method button opens Credit Card, PayPal and Bank Transfer, each with an icon, and Credit Card chosen. Use it when the options are a familiar set of brands or kinds that people recognize by their picture. The words still name each option, and the icons carry aria-hidden.

Preview width

Destructive

Edit and Share, then Delete below a separator with variant set to destructive, which colors the row as a warning. The variant changes the color and nothing else: it doesn't ask for confirmation. When the action can't be undone, open a confirmation from the item, as the Actions demo does, and keep the dangerous row last.

Preview width

Avatar

A round avatar is the trigger, opening Account, Billing and Notifications, then Sign Out below a separator. Use it for the account menu in an app header, where people already look for their own picture. The button's only text is the image's alt, so make that the person's name, or give the button an aria-label such as Account menu.

Preview width

Complex

File, View and Account sections in one menu, with shortcut hints, submenus two levels deep, view checkboxes, a theme radio group and a destructive Sign Out. Read it as a reference for how the parts combine rather than a menu to ship. A list this long hides what people came for, and an app's main commands belong in a Menubar.

Preview width

Actions

An ellipsis button on a Project Alpha row, labelled Actions for Project Alpha, opens Edit, Duplicate and Delete. One select handler on DropdownMenu reads the chosen item's value. Edit and Duplicate write the result into a live region under the row, and Delete opens an alert dialog first. Copy this for row actions in a table or list.

Preview width

RTL

Arabic labels from an account submenu through view checkboxes, a position radio group and a destructive log out. dir is rtl on DropdownMenu, which passes the direction to every panel, so the text and chevrons turn around, submenus open to the left and ArrowLeft opens them. Use it on Arabic or Hebrew pages.

Preview width

FAQ

How do I open or close a Dropdown Menu from my own state in Vue?

Bind v-model:open on DropdownMenu, which reads and writes a boolean. If you need a handler as well, @open-change fires on every change, with the new flag in details.open, including when an item is chosen, on Escape and on a click outside.

With the state in your hands, a keyboard shortcut elsewhere on the page can open the menu, and code that finishes later can close it.

How do I run code when a Dropdown Menu item is chosen?

Listen for @select on DropdownMenu: it receives details.value, the value of the chosen item, so one handler can branch on it, as the Actions demo does. The menu closes after a choice. Set closeOnSelect to false on DropdownMenu, or on one item, to keep it open.

How do I add checkbox or radio items to a Dropdown Menu?

Bind v-model:checked on each DropdownMenuCheckboxItem, and v-model on a DropdownMenuRadioGroup of DropdownMenuRadioItem rows, where it holds the chosen item's value. Both parts emit only their update: events, so @checked-change and @value-change listeners never run. Like any item, these close the menu when chosen, unless you set closeOnSelect to false on them.

The Checkboxes and Radio group demos still listen with those two events, so their marks don't move.

How do I change where a Dropdown Menu opens and how wide it is?

Pass positioning to DropdownMenu with a placement such as bottom-start. This file defaults to bottom-end, and the menu flips above the trigger when there's no room below. The content otherwise grows with its longest item, so add a width class to DropdownMenuContent for a fixed width, or set sameWidth to true in positioning to match the trigger.

How do I open a Dialog from a Dropdown Menu item?

Render the dialog beside the menu, not inside DropdownMenuContent, and open it from state that the item sets. Choosing the item closes the menu and unmounts what's inside it, so a dialog placed there would disappear with it.

In the Actions demo, the select handler on DropdownMenu sets confirming when details.value is delete, and the AlertDialog under the row takes it as open.

Why can't I scroll the page while a Dropdown Menu is open?

Nothing locks it on Ark UI: the menu isn't modal. The page keeps scrolling while the menu is open, the menu stays attached to its trigger as the page moves, and a click outside closes it. If scrolling stops, something else has locked it, such as a modal dialog the menu sits in.

Should I use a Dropdown Menu, a Select or a Context Menu?

Use a Dropdown Menu when a visible button opens a list of actions, such as Edit, Duplicate and Delete on a row, or Profile and Sign out under an avatar. Each item does something when chosen, and only checkbox and radio rows keep a state.

Use a Select when the choice is a value a form keeps and the closed control should show it. A Context Menu holds the same kind of actions but opens with a right-click on an area, so keep a visible button for anything people need to find.

API Reference

data-slot="menu"

PropType
open?boolean

The controlled open state of the menu. Two-way with v-model:open.

defaultOpen?boolean

The initial open state of the menu when rendered. Use when you don't need to control the open state of the menu.

triggerValue?string | null

The controlled trigger value. Two-way with v-model:triggerValue.

Type
string | null
defaultTriggerValue?string | null

The initial trigger value when rendered. Use when you don't need to control the trigger value.

Type
string | null
anchorPoint?Point | null

The positioning point for the menu. Can be set by the context menu trigger or the button trigger.

Type
Point | null
closeOnSelect?boolean

Whether to close the menu when an option is selected.

Default
true
composite?boolean

Whether the menu is a composed with other composite widgets like a combobox or tabs.

Default
true
defaultHighlightedValue?string | null

The initial highlighted value of the menu item when rendered. Use when you don't need to control the highlighted value of the menu item.

Type
string | null
dir?"ltr" | "rtl"

The reading direction. Inherits the nearest DirectionProvider when unset.

Type
"ltr" | "rtl"
hideMode?"display-none" | "activity"

How to hide content when mounted but not present. - display-none: HTML hidden attribute. Effects stay alive. - activity: React 19 <Activity mode="hidden">. Effects pause. Requires React 19+.

Type
"display-none" | "activity"
Default
"display-none"
highlightedValue?string | null

The controlled highlighted value of the menu item.

Type
string | null
id?string

The unique identifier of the machine.

ids?object

The ids of the elements in the menu. Useful for composition.

Type
{ trigger?: string | ((value?: string) → string); contextTrigger?: string | ((value?: string) → string); content?: string; groupLabel?: (id: string) → string; group?: (id: string) → string; positioner?: string; arrow?: string }
immediate?boolean

Whether to synchronize the present change immediately or defer it to the next frame.

lazyMount?boolean

Whether to enable lazy mounting. Ark default: false.

Default
true
loopFocus?boolean

Whether to loop the keyboard navigation.

Default
false
navigate?((details: NavigateDetails) → void) | null

Function to navigate to the selected item if it's an anchor element.

Type
((details: NavigateDetails) → void) | null
Parameters

(details – { value: string; node: HTMLAnchorElement; href: string }

Returns
void) | null
onEnterComplete?VoidFunction

Function called when the animation ends in the open state.

onExitComplete?VoidFunction

Function called when the animation ends in the closed state.

positioning?object

The options used to dynamically position the menu.

Type
{ restoreStyles?: boolean; applyStyles?: boolean; hideWhenDetached?: boolean; strategy?: "absolute" | "fixed"; placement?: Placement; offset?: { mainAxis?: number; crossAxis?: number; }; gutter?: number; shift?: number; overflowPadding?: number; arrowPadding?: number; flip?: boolean | Placement[]; slide?: boolean; overlap?: boolean; sameWidth?: boolean; fitViewport?: boolean; sizeMiddleware?: boolean; boundary?: (() → Boundary) | Boundary | "clipping-ancestors"; listeners?: boolean | AutoUpdateOptions; onComplete?: (data: ComputePositionReturn) → void; onPositioned?: ((data: { placed: boolean; }) → void); getAnchorElement?: () → HTMLElement | VirtualElement | null; getAnchorRect?: (element: HTMLElement | VirtualElement | null) → AnchorRect | null; updatePosition?: ((data: { updatePosition: () → Promise<void>; floatingElement: HTMLElement | null; }) → void | Promise<void>) }
present?boolean

Whether the node is present (controlled by the user).

skipAnimationOnMount?boolean

Whether to allow the initial presence animation.

Default
false
typeahead?boolean

Whether the pressing printable characters should trigger typeahead navigation.

Default
true
unmountOnExit?boolean

Whether to unmount on exit. Ark default: false.

Default
true
EventType
@open-change(details: OpenChangeDetails) → void

Function called when the menu opens or closes.

Type
(details: OpenChangeDetails) → void
Parameters

details – { open: boolean }

Returns
void
@trigger-value-change(details: TriggerValueChangeDetails) → void

Function called when the trigger value changes.

Type
(details: TriggerValueChangeDetails) → void
Parameters

details – { value: string | null; triggerElement: HTMLElement | null }

Returns
void
@escape-key-down(event: KeyboardEvent) → void

Function called when the escape key is pressed.

Parameters

event – { altKey: boolean; charCode: number; ctrlKey: boolean; code: string; getModifierState: (key: string) → boolean; key: string; keyCode: number; locale: string; location: number; metaKey: boolean; repeat: boolean; shiftKey: boolean; which: number }

Returns
void
@focus-outside(event: FocusOutsideEvent) → void

Function called when the focus is moved outside the component.

Type
(event: FocusOutsideEvent) → void
Parameters

event – FocusOutsideEvent

Returns
void
@highlight-change(details: HighlightChangeDetails) → void

Function called when the highlighted menu item changes.

Type
(details: HighlightChangeDetails) → void
Parameters

details – { highlightedValue: string | null }

Returns
void
@interact-outside(event: InteractOutsideEvent) → void

Function called when an interaction happens outside the component.

Type
(event: InteractOutsideEvent) → void
Parameters

event – InteractOutsideEvent

Returns
void
@pointer-down-outside(event: PointerDownOutsideEvent) → void

Function called when the pointer is pressed down outside the component.

Type
(event: PointerDownOutsideEvent) → void
Parameters

event – PointerDownOutsideEvent

Returns
void
@request-dismiss(event: LayerDismissEvent) → void

Function called when this layer is closed due to a parent layer being closed.

Type
(event: LayerDismissEvent) → void
Parameters

event – LayerDismissEvent

Returns
void
@select(details: SelectionDetails) → void

Function called when a menu item is selected.

Type
(details: SelectionDetails) → void
Parameters

details – { value: string }

Returns
void

<div>

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

class?string

Merged with the part's classes.

CSS variableType
--arrow-backgroundstring

Use this variable to style the arrow background.

--arrow-offsetstring

The offset position of the arrow.

--arrow-sizestring

The size of the arrow.

--arrow-size-halfstring

Half the size of the arrow.

<div> data-slot="menu-sub-content"

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

class?string

Merged with the part's classes.

AttributeType
data-has-nested?string

Present when another menu is nested inside it.

data-instant?string
data-nested?string

Present when it's nested inside another menu.

data-placementstring

The placement of the content.

data-side"top" | "right" | "bottom" | "left"

The side of the trigger that the content is positioned on.

Type
"top" | "right" | "bottom" | "left"
data-state"open" | "closed"

"open" or "closed".

Type
"open" | "closed"
CSS variableType
--available-heightstring

The height left between the anchor and the viewport's edge.

--layer-indexstring

The index of the dismissable in the layer stack.

--nested-layer-countstring

The number of nested menus.

--transform-originstring

Where the content scales from, on its trigger's side.

<div>

PropType
valuestring

The unique value of the menu item option.

checked?boolean

Whether it's checked.

disabled?boolean

Whether the menu item is disabled.

valueText?string

The textual value of the option. Used in typeahead navigation of the menu. If not provided, the text content of the menu item will be used.

variant?"default" | "destructive"

The visual style.

Type
"default" | "destructive"
Default
"default"
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

class?string

Merged with the part's classes.

AttributeType
data-disabled?string

Present when disabled.

data-highlighted?string

Present when highlighted.

data-ownedbystring

Id of the content part.

data-valuestring

The value of the item.

data-valuetextstring

The human-readable value.

data-variant?string

Mirrors variant.

<div> data-slot="menu-group"

PropType
heading?string

The heading of the menu item group.

asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

<div> data-slot="menu-group-label"

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

class?string

Merged with the part's classes.

<div> data-slot="menu-positioner"

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

class?string

Merged with the part's classes.

AttributeType
data-has-nested?string

Present when the positioner has nested menus.

data-instant?string
data-nested?string

Present when the positioner is nested within another menu.

CSS variableType
--available-heightstring

The available height in viewport.

--available-widthstring

The available width in viewport.

--reference-heightstring

The height of the root.

--reference-widthstring

The width of the reference element.

--transform-originstring

The transform origin for animations.

--xstring

The x position for transform.

--ystring

The y position for transform.

--z-indexstring

The z-index value.

<hr> data-slot="menu-separator"

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

class?string

Merged with the part's classes.

<button> data-slot="menu-trigger"

PropType
value?string

The value that identifies this specific trigger.

asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

AttributeType
data-controls?string
data-current?string

Present when current.

data-disabled?string

Present when disabled.

data-placement?string

The placement of the trigger.

data-side?string

The side of the trigger that the trigger is positioned on.

data-state"open" | "closed"

"open" or "closed".

Type
"open" | "closed"
data-value?string

The value of the item.

<div> data-slot="menu-sub-trigger"

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

class?string

Merged with the part's classes.

<div> data-slot="menu-content"

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

class?string

Merged with the part's classes.

AttributeType
data-has-nested?string

Present when another menu is nested inside it.

data-instant?string
data-nested?string

Present when it's nested inside another menu.

data-placementstring

The placement of the content.

data-side"top" | "right" | "bottom" | "left"

The side of the trigger that the content is positioned on.

Type
"top" | "right" | "bottom" | "left"
data-state"open" | "closed"

"open" or "closed".

Type
"open" | "closed"
CSS variableType
--available-heightstring

The height left between the anchor and the viewport's edge.

--layer-indexstring

The index of the dismissable in the layer stack.

--nested-layer-countstring

The number of nested menus.

--transform-originstring

Where the content scales from, on its trigger's side.

<div>

PropType
valuestring

The unique value of the menu item option.

checked?boolean

Whether it's checked.

disabled?boolean

Whether the menu item is disabled.

valueText?string

The textual value of the option. Used in typeahead navigation of the menu. If not provided, the text content of the menu item will be used.

variant?"default" | "destructive"

The visual style.

Type
"default" | "destructive"
Default
"default"
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

class?string

Merged with the part's classes.

AttributeType
data-disabled?string

Present when disabled.

data-highlighted?string

Present when highlighted.

data-ownedbystring

Id of the content part.

data-valuestring

The value of the item.

data-valuetextstring

The human-readable value.

data-variant?string

Mirrors variant.

<div>

PropType
valuestring

The value of the option.

closeOnSelect?boolean

Whether the menu should be closed when the option is selected.

disabled?boolean

Whether the menu item is disabled.

valueText?string

The textual value of the option. Used in typeahead navigation of the menu. If not provided, the text content of the menu item will be used.

asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

class?string

Merged with the part's classes.

<div> data-slot="menu-radio-group"

PropType
heading?string

The heading of the menu radio item group.

asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

<div> data-slot="menu-radio-item"

PropType
valuestring

The value of the option.

closeOnSelect?boolean

Whether the menu should be closed when the option is selected.

disabled?boolean

Whether the menu item is disabled.

valueText?string

The textual value of the option. Used in typeahead navigation of the menu. If not provided, the text content of the menu item will be used.

asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

class?string

Merged with the part's classes.

data-slot="menu-sub"

PropType
open?boolean

The controlled open state of the menu. Two-way with v-model:open.

defaultOpen?boolean

The initial open state of the menu when rendered. Use when you don't need to control the open state of the menu.

triggerValue?string | null

The controlled trigger value. Two-way with v-model:triggerValue.

Type
string | null
defaultTriggerValue?string | null

The initial trigger value when rendered. Use when you don't need to control the trigger value.

Type
string | null
anchorPoint?Point | null

The positioning point for the menu. Can be set by the context menu trigger or the button trigger.

Type
Point | null
closeOnSelect?boolean

Whether to close the menu when an option is selected.

Default
true
composite?boolean

Whether the menu is a composed with other composite widgets like a combobox or tabs.

Default
true
defaultHighlightedValue?string | null

The initial highlighted value of the menu item when rendered. Use when you don't need to control the highlighted value of the menu item.

Type
string | null
dir?"ltr" | "rtl"

The reading direction. Inherits the nearest DirectionProvider when unset.

Type
"ltr" | "rtl"
hideMode?"display-none" | "activity"

How to hide content when mounted but not present. - display-none: HTML hidden attribute. Effects stay alive. - activity: React 19 <Activity mode="hidden">. Effects pause. Requires React 19+.

Type
"display-none" | "activity"
Default
"display-none"
highlightedValue?string | null

The controlled highlighted value of the menu item.

Type
string | null
id?string

The unique identifier of the machine.

ids?object

The ids of the elements in the menu. Useful for composition.

Type
{ trigger?: string | ((value?: string) → string); contextTrigger?: string | ((value?: string) → string); content?: string; groupLabel?: (id: string) → string; group?: (id: string) → string; positioner?: string; arrow?: string }
immediate?boolean

Whether to synchronize the present change immediately or defer it to the next frame.

lazyMount?boolean

Whether to enable lazy mounting.

Default
false
loopFocus?boolean

Whether to loop the keyboard navigation.

Default
false
navigate?((details: NavigateDetails) → void) | null

Function to navigate to the selected item if it's an anchor element.

Type
((details: NavigateDetails) → void) | null
Parameters

(details – { value: string; node: HTMLAnchorElement; href: string }

Returns
void) | null
onEnterComplete?VoidFunction

Function called when the animation ends in the open state.

onExitComplete?VoidFunction

Function called when the animation ends in the closed state.

positioning?object

The options used to dynamically position the menu.

Type
{ restoreStyles?: boolean; applyStyles?: boolean; hideWhenDetached?: boolean; strategy?: "absolute" | "fixed"; placement?: Placement; offset?: { mainAxis?: number; crossAxis?: number; }; gutter?: number; shift?: number; overflowPadding?: number; arrowPadding?: number; flip?: boolean | Placement[]; slide?: boolean; overlap?: boolean; sameWidth?: boolean; fitViewport?: boolean; sizeMiddleware?: boolean; boundary?: (() → Boundary) | Boundary | "clipping-ancestors"; listeners?: boolean | AutoUpdateOptions; onComplete?: (data: ComputePositionReturn) → void; onPositioned?: ((data: { placed: boolean; }) → void); getAnchorElement?: () → HTMLElement | VirtualElement | null; getAnchorRect?: (element: HTMLElement | VirtualElement | null) → AnchorRect | null; updatePosition?: ((data: { updatePosition: () → Promise<void>; floatingElement: HTMLElement | null; }) → void | Promise<void>) }
present?boolean

Whether the node is present (controlled by the user).

skipAnimationOnMount?boolean

Whether to allow the initial presence animation.

Default
false
typeahead?boolean

Whether the pressing printable characters should trigger typeahead navigation.

Default
true
unmountOnExit?boolean

Whether to unmount on exit.

Default
false
EventType
@open-change(details: OpenChangeDetails) → void

Function called when the menu opens or closes.

Type
(details: OpenChangeDetails) → void
Parameters

details – { open: boolean }

Returns
void
@trigger-value-change(details: TriggerValueChangeDetails) → void

Function called when the trigger value changes.

Type
(details: TriggerValueChangeDetails) → void
Parameters

details – { value: string | null; triggerElement: HTMLElement | null }

Returns
void
@escape-key-down(event: KeyboardEvent) → void

Function called when the escape key is pressed.

Parameters

event – { altKey: boolean; charCode: number; ctrlKey: boolean; code: string; getModifierState: (key: string) → boolean; key: string; keyCode: number; locale: string; location: number; metaKey: boolean; repeat: boolean; shiftKey: boolean; which: number }

Returns
void
@focus-outside(event: FocusOutsideEvent) → void

Function called when the focus is moved outside the component.

Type
(event: FocusOutsideEvent) → void
Parameters

event – FocusOutsideEvent

Returns
void
@highlight-change(details: HighlightChangeDetails) → void

Function called when the highlighted menu item changes.

Type
(details: HighlightChangeDetails) → void
Parameters

details – { highlightedValue: string | null }

Returns
void
@interact-outside(event: InteractOutsideEvent) → void

Function called when an interaction happens outside the component.

Type
(event: InteractOutsideEvent) → void
Parameters

event – InteractOutsideEvent

Returns
void
@pointer-down-outside(event: PointerDownOutsideEvent) → void

Function called when the pointer is pressed down outside the component.

Type
(event: PointerDownOutsideEvent) → void
Parameters

event – PointerDownOutsideEvent

Returns
void
@request-dismiss(event: LayerDismissEvent) → void

Function called when this layer is closed due to a parent layer being closed.

Type
(event: LayerDismissEvent) → void
Parameters

event – LayerDismissEvent

Returns
void
@select(details: SelectionDetails) → void

Function called when a menu item is selected.

Type
(details: SelectionDetails) → void
Parameters

details – { value: string }

Returns
void

<span> data-slot="menu-shortcut"

PropType
asChild?boolean

Use the provided child element as the default rendered element, combining their props and behavior.

class?string

Merged with the part's classes.

useDropdownMenu

PropType
open?boolean

The controlled open state of the menu. Two-way with v-model:open.

defaultOpen?boolean

The initial open state of the menu when rendered. Use when you don't need to control the open state of the menu.

triggerValue?string | null

The controlled trigger value. Two-way with v-model:triggerValue.

Type
string | null
defaultTriggerValue?string | null

The initial trigger value when rendered. Use when you don't need to control the trigger value.

Type
string | null
anchorPoint?Point | null

The positioning point for the menu. Can be set by the context menu trigger or the button trigger.

Type
Point | null
closeOnSelect?boolean

Whether to close the menu when an option is selected.

Default
true
composite?boolean

Whether the menu is a composed with other composite widgets like a combobox or tabs.

Default
true
defaultHighlightedValue?string | null

The initial highlighted value of the menu item when rendered. Use when you don't need to control the highlighted value of the menu item.

Type
string | null
highlightedValue?string | null

The controlled highlighted value of the menu item.

Type
string | null
id?string

The unique identifier of the machine.

ids?object

The ids of the elements in the menu. Useful for composition.

Type
{ trigger?: string | ((value?: string) → string); contextTrigger?: string | ((value?: string) → string); content?: string; groupLabel?: (id: string) → string; group?: (id: string) → string; positioner?: string; arrow?: string }
loopFocus?boolean

Whether to loop the keyboard navigation.

Default
false
navigate?((details: NavigateDetails) → void) | null

Function to navigate to the selected item if it's an anchor element.

Type
((details: NavigateDetails) → void) | null
Parameters

(details – { value: string; node: HTMLAnchorElement; href: string }

Returns
void) | null
positioning?object

The options used to dynamically position the menu.

Type
{ restoreStyles?: boolean; applyStyles?: boolean; hideWhenDetached?: boolean; strategy?: "absolute" | "fixed"; placement?: Placement; offset?: { mainAxis?: number; crossAxis?: number; }; gutter?: number; shift?: number; overflowPadding?: number; arrowPadding?: number; flip?: boolean | Placement[]; slide?: boolean; overlap?: boolean; sameWidth?: boolean; fitViewport?: boolean; sizeMiddleware?: boolean; boundary?: (() → Boundary) | Boundary | "clipping-ancestors"; listeners?: boolean | AutoUpdateOptions; onComplete?: (data: ComputePositionReturn) → void; onPositioned?: ((data: { placed: boolean; }) → void); getAnchorElement?: () → HTMLElement | VirtualElement | null; getAnchorRect?: (element: HTMLElement | VirtualElement | null) → AnchorRect | null; updatePosition?: ((data: { updatePosition: () → Promise<void>; floatingElement: HTMLElement | null; }) → void | Promise<void>) }
typeahead?boolean

Whether the pressing printable characters should trigger typeahead navigation.

Default
true
EventType
@open-change(details: OpenChangeDetails) → void

Function called when the menu opens or closes.

Type
(details: OpenChangeDetails) → void
Parameters

details – { open: boolean }

Returns
void
@trigger-value-change(details: TriggerValueChangeDetails) → void

Function called when the trigger value changes.

Type
(details: TriggerValueChangeDetails) → void
Parameters

details – { value: string | null; triggerElement: HTMLElement | null }

Returns
void
@escape-key-down(event: KeyboardEvent) → void

Function called when the escape key is pressed.

Parameters

event – { altKey: boolean; charCode: number; ctrlKey: boolean; code: string; getModifierState: (key: string) → boolean; key: string; keyCode: number; locale: string; location: number; metaKey: boolean; repeat: boolean; shiftKey: boolean; which: number }

Returns
void
@focus-outside(event: FocusOutsideEvent) → void

Function called when the focus is moved outside the component.

Type
(event: FocusOutsideEvent) → void
Parameters

event – FocusOutsideEvent

Returns
void
@highlight-change(details: HighlightChangeDetails) → void

Function called when the highlighted menu item changes.

Type
(details: HighlightChangeDetails) → void
Parameters

details – { highlightedValue: string | null }

Returns
void
@interact-outside(event: InteractOutsideEvent) → void

Function called when an interaction happens outside the component.

Type
(event: InteractOutsideEvent) → void
Parameters

event – InteractOutsideEvent

Returns
void
@pointer-down-outside(event: PointerDownOutsideEvent) → void

Function called when the pointer is pressed down outside the component.

Type
(event: PointerDownOutsideEvent) → void
Parameters

event – PointerDownOutsideEvent

Returns
void
@request-dismiss(event: LayerDismissEvent) → void

Function called when this layer is closed due to a parent layer being closed.

Type
(event: LayerDismissEvent) → void
Parameters

event – LayerDismissEvent

Returns
void
@select(details: SelectionDetails) → void

Function called when a menu item is selected.

Type
(details: SelectionDetails) → void
Parameters

details – { value: string }

Returns
void