Set it to true/false to programatically show or hide dropdown content. Model is optional
auto-close-menufalse
Boolean
If true clicking any dropdown menu item automatically closes dropdown
auto-placementfalse
Boolean
Automatically calculates best placement for floating element
base"dropdown"
String
Base name used to style component
fliptrue
Boolean
Allows fliping dropdown to opposite placement if outside of current view
mod-headerempty string
String
Style of the menu header
mod-itemempty string
String
Style of the menu item
nameempty string
String
Name of the component
offset-x0
Number
Offset of dropdown relative to reference element. See how to use this offset here
offset-y0
Number
Offset of dropdown relative to reference element. See how to use this offset here
placement"bottom-start"
String
Initial placement of dropdown content. See valid values in FloatingUI documentation
transition"fade-scale"
String
Sets animation effect when showing or hiding dropdown. Valid values are: 'fade', 'fade-slide', 'fade-scale' or empty string to disable animations. CSS variables: --dropdown-transition-duration, --dropdown-transition-slide, --dropdown-transition-scale
trigger"click"
String
How to trigger dropdown. Valid triggers are 'click', 'focus' and 'hover'
variantempty string
String
Active variant of the element mod-* props
Events
state:opened
Emitted after dropdown is opened
state:closed
Emitted after dropdown is closed
update:modelValue
Emitted after model change
Slots
reference
Slot for element that activates dropdown. Dropdown is positioned relative to element that has ref set to reference. Slot props: reference, onTrigger and isOpen
<template><v-dropdownauto-close-menu:offsetY="5"
><template #reference="{ reference, onTrigger }"><v-button-chevron:ref="reference":chevron="{ class: 'ml-2' }"v-on="onTrigger"
>
Dropdown menu
</v-button-chevron></template><v-cardwidth="320px"
><v-dropdown-menu-itemtag="button">
Menu item
</v-dropdown-menu-item><v-dropdown-menu-itemtag="button">
Second menu item
</v-dropdown-menu-item><v-dropdown-menu-itemactivetag="button"
>
Active menu item
</v-dropdown-menu-item><v-dropdown-menu-itemtag="button">
Third menu item
</v-dropdown-menu-item></v-card></v-dropdown></template>
<template><!-- relaxed --><v-dropdownbase="relaxedDropdown":offsetY="5"
><template #reference="{ reference, onTrigger }"><v-button-chevron:ref="reference":chevron="{ class: 'ml-2' }"class="mr-4"v-on="onTrigger"
>
Dropdown menu (relaxed)
</v-button-chevron></template><v-cardwidth="320px"class="flex flex-col items-center py-3"
><v-dropdown-menu-itemtag="button">
Menu item
</v-dropdown-menu-item><v-dropdown-menu-itemtag="button">
Second menu item
</v-dropdown-menu-item><v-dropdown-header>
Menu header
</v-dropdown-header><v-dropdown-menu-itemtag="button">
Menu item
</v-dropdown-menu-item><v-dropdown-menu-itemtag="button">
Another menu item
</v-dropdown-menu-item><v-dividerclass="w-11/12 mx-auto" /><v-dropdown-menu-itemdisabledtag="button"
>
Disabled menu item
</v-dropdown-menu-item><v-dropdown-menu-itemtag="button">
Menu item
</v-dropdown-menu-item></v-card></v-dropdown><!-- flat --><v-dropdown:offsetY="5"
><template #reference="{ reference, onTrigger }"><v-button-chevron:ref="reference"mod-button="shape:square":chevron="{ class: 'ml-2' }"v-on="onTrigger"class="mt-4 md:mt-0"
>
Dropdown menu (flat)
</v-button-chevron></template><v-cardwidth="320px"mod-card="preset:flatDropdown"
><v-dropdown-menu-itemtag="button">
Menu item
</v-dropdown-menu-item><v-dropdown-menu-itemtag="button">
Second menu item
</v-dropdown-menu-item><v-dropdown-header>
Menu header
</v-dropdown-header><v-dropdown-menu-itemtag="button">
Menu item
</v-dropdown-menu-item><v-dropdown-menu-itemtag="button">
Another menu item
</v-dropdown-menu-item><v-dividerclass="w-11/12 mx-auto" /><v-dropdown-menu-itemdisabledtag="button"
>
Disabled menu item
</v-dropdown-menu-item><v-dropdown-menu-itemtag="button">
Menu item
</v-dropdown-menu-item></v-card></v-dropdown></template>
Example - custom content
Dropdowns are not limited to simple dropdown menus. See the below example for more advanced dropdown that uses input to filter menu items.
You can also control state of the dropdown menu by using v-trigger component. The for prop of the v-trigger should be the same as id of the dropdown. The advantage of this method is that v-triggers can be put anywhere in application. Read more about v-trigger here.
<template><v-dropdownid="dropdown":offsetY="5"><v-cardwidth="320px"><v-dropdown-menu-itemtag="button">
Menu item
</v-dropdown-menu-item><v-dropdown-menu-itemtag="button">
Second menu item
</v-dropdown-menu-item><v-dropdown-header>
Menu header
</v-dropdown-header><v-dropdown-menu-itemtag="button">
Active menu item
</v-dropdown-menu-item><v-dropdown-menu-itemtag="button">
Another menu item
</v-dropdown-menu-item><v-divider /><v-dropdown-menu-itemdisabledtag="button">
Disabled menu item
</v-dropdown-menu-item><v-dropdown-menu-itemtag="button">
Menu item
</v-dropdown-menu-item></v-card></v-dropdown><v-triggerfor="dropdown"v-slot="{ reference, onTrigger, isOpen }"><v-button:ref="reference"v-on="onTrigger">
Dropdown menu
<v-chevronrotate180:switch="isOpen"class="ml-2"></v-chevron></v-button></v-trigger></template>
Example - context dropdown
To make context menu use v-dropdown-context. This component exposes showContextDropdown($event, { contextData }) function that controls visibility state of the menu and sets context data. The first argument, mouse event, allows computing position of the menu. The second argument defines data that is provided in the default slot of the dropdown component.