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.
Installation
Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.
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.
KeyAction
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.
EscEscape
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.
Submenu
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
How do I use a router link as a Dropdown Menu item?
Render your router's link through asChild on DropdownMenuItem, the way the demos render the trigger's button, and keep the item's value. The anchor takes the item's menuitem role and highlight, while the keys stay with the menu: Enter on the highlighted link clicks it, so your router handles it like a pointer click, and the menu closes.
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
DropdownMenu
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.
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
DropdownMenuArrow
<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.
DropdownMenuSubContent
<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.
DropdownMenuQuickItem
<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.
DropdownMenuGroup
<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.
DropdownMenuLabel
<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.
DropdownMenuPositioner
<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.
DropdownMenuSeparator
<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.
DropdownMenuTrigger
<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.
DropdownMenuSubTrigger
<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.
DropdownMenuContent
<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.
DropdownMenuItem
<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.
DropdownMenuCheckboxItem
<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.
DropdownMenuRadioGroup
<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.
DropdownMenuRadioItem
<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.
DropdownMenuSub
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.