Skip to content
🌏 Translated with the assistance of DeepSeek and ChatGPT

DropDown

A compact menu displayed via a dropdown.

Basic Usage

Set menu content using the options prop. When an option is a string or an object, its index field will be used as the option's unique identifier — make sure they are not duplicated.

Use the select event to get the triggered option.

options determines whether to render the options as <a> tags or Vue Router RouterLink components based on the href or route field of the child elements.

WARNING

The href and route will be directly rendered into the <a> tag. If values such as javascript:alert(1) or malicious URLs are passed, this may lead to XSS or open redirect vulnerabilities.

Hide source code

Placement

The DropDown popup supports multiple placements.

The placement prop determines where the popup appears. The value format is [direction]-[alignment], such as 'top', 'right', 'bottom', 'left', 'top-start', 'top-end', 'right-start', 'right-end', 'bottom-start', 'bottom-end', 'left-start', 'left-end'. There are four directions and three alignment variations. Default placement is top.

Hide source code

Grouped Menus

Options can be grouped.

Hide source code

Split Button

Combine ButtonGroup and Button components so an icon button can trigger the popup.

Hide source code

Controlled Mode

Passing visible switches the component to controlled mode. If omitted or set to undefined, the component is uncontrolled and defaultVisible can be used to set the initial state. The component emits update:visible to support v-model.

Hide source code

Disabled State

Set disabled to disable the component. Trigger actions will be ignored and the popup will not open.

Hide source code

Slot Usage

Dropdown provides option and group-label slots for customizing the rendering of menu items and group headers.

Hide source code

API

AttributeTypeOptionalDefaultDescriptionVersion
optionsDropDownOption | DropDownGroupOptionTrueDropdown menu contents.0.1.0
visibleboolean | nullTrueWhether it is shown (controlled mode, supports v-model).0.1.0
defaultVisibleboolean | nullTrueDefault visibility in uncontrolled mode.0.1.0
placement'top' | 'right' | 'bottom' | 'left' | 'top-start' | 'top-end' | 'right-start' | 'right-end' | 'bottom-start' | 'bottom-end' | 'left-start' | 'left-end'True'top'Popup placement.0.1.0
trigger'hover' | 'click'True'hover'Trigger action.0.1.0
disabledbooleanTruebooleanWhether the component is disabled.0.1.0
offsetnumberTrue8Popup offset in pixels.0.1.0
variant'dark' | 'light'True'light'Component style variant.0.1.0
arrowbooleanTruetrueWhether to show an arrow.0.1.0
rootHTMLElement | stringTrue'body'Mount element.0.1.0
zIndexnumberTruez-index for the popup.0.1.0
animationDurationnumberTrue250Duration of the popup show/hide animation.0.1.5
destroyOnHidebooleanTruefalseWhether to destroy content when hidden.0.1.0
popoverPropsOmit<PopoverProps, 'visible' | 'content' | 'defaultVisible'> & EmitEvent<PopoverEvents>TrueProps forwarded to the internal Popover.0.1.0
dividerPropsRestAttrsTrueDOM attributes forwarded to the divider element.0.1.0
EventParameterDescriptionVersion
update:visiblevalue: booleanCallback for updating visible.0.1.0
closeevent: MouseEventFired when the popup closes.0.1.0
openevent: MouseEventFired when the popup opens.0.1.0
selectindex: string | number | symbol, option: DropDownOption | string, event: MouseEventFired when a menu option is selected.0.1.0
SlotParameterDescriptionVersion
defaultTrigger element slot.0.1.0
optionitem: string | DropDownOptionCustom rendering for an option.0.1.5
group-labelitem: DropDownGroupOptionCustom rendering for the group header.0.1.5
AttributeTypeOptionalDefaultDescriptionVersion
open() => voidFalseOpens the popup.0.1.0
close() => voidFalseCloses the popup.0.1.0

RestAttrs

ts
import type { StyleValue } from 'vue'

export type VueClassValue = string | Record<string, any> | VueClassValue[]
export type VueStyleValue = StyleValue

export type RestAttrs = {
	style?: VueStyleValue | null
	class?: VueClassValue | null
	[x: string]: any
}

EmitEvent

ts
export type EmitEvent<T extends Record<string, any>> = {
	[K in keyof T as `on${Capitalize<K & string>}`]?: (...args: T[K]) => void
}
ts
export interface DropDownOption extends NavigationOption {
	divider?: boolean
	disabled?: boolean
	href?: string
	route?: string | object
	target?: string
}

export interface DropDownGroupOption extends NavigationOption {
	children: (DropDownOption | string)[]
	type: 'group'
}

export interface NavigationOption {
	index: string | number | symbol
	label?: string
}