| sidebarDepth | 2 |
|---|
The Dropdown component is highly versatile and can be used in various ways, such as for displaying lists as contextual overlays, as a quick menu, or as a selectable list of content options.
Unlike native select elements, the dropdown input allows you to customize both its appearance and behavior. The component implements both the W3C ARIA APG Combobox Pattern as well as the W3C ARIA APG Menu Button Pattern, depending on whether the options are selectable.
Dropdowns are very versatile, can used as a quick menu or even like a select for discoverable content.
<o-dropdown></o-dropdown>| Prop name | Description | Type | Values | Default |
|---|---|---|---|---|
| active | The active state of the dropdown, use v-model:active to make it two-way binding | boolean | - | false |
| animation | Custom animation (transition name) | string | - | From config: dropdown: { |
| ariaLabel | Accessibility aria-label to be passed to the trigger element - usefull if selectable | string | - | |
| clipScroll | Set true to remove the body scrollbar.When false, a non-scrollable scrollbar will be kept to avoid moving the background,but will set the body to a fixed position, which may break some layouts. |
boolean | - | From config: dropdown: { |
| closeOnOutside | Close Dropdown when clicked outside | boolean | - | From config: dropdown: { |
| closeOnScroll | Close Dropdown when page get scrolled | boolean | - | From config: dropdown: { |
| delay | Dropdown delay before it appears (number in ms) | number | - | |
| desktopModal | Dropdown content (items) are shown into a modal on desktop | boolean | - | From config: dropdown: { |
| disabled | Interaction is disabled | boolean | - | false |
| expanded | Dropdown will be expanded (full-width) | boolean | - | false |
deprecated - since 0.13.0, use the OListbox component instead |
boolean | - | false |
|
| itemTag | Dropdown item tag name | DynamicComponent | - | From config: dropdown: { |
| keepFirst | The first option will always be pre-selected (easier to just hit enter or tab) | boolean | - | From config: dropdown: { |
| keepOpen | Keep dropdown list open when item get selected | boolean | - | From config: dropdown: { |
| label | Trigger label, unnecessary when trigger slot is used | string | - | |
| labelledby | Ensures that each input has an accessible name. | string | - | |
| maxHeight | Max height of dropdown content | Numberish | - | From config: dropdown: { |
| menuId | HTML element Id of the dropdown menu element | string | - | useId() |
| menuTag | Dropdown menu tag name | DynamicComponent | - | From config: dropdown: { |
| mobileBreakpoint | Mobile breakpoint as max-width value |
string | - | From config: dropdown: { |
| mobileModal | Dropdown content (items) are shown into a modal on mobile | boolean | - | From config: dropdown: { |
| v-model | The selected option value, use v-model to make it two-way binding | ValueType<unknown, IsMultiple> | - | |
| multiple | Allows multiple selections - converts the modelValue into an array |
IsMultiple | - | |
| openOnClick | Show when clicked on the trigger | boolean | - | From config: tooltip: { |
| openOnContextmenu | Show when right clicked on the trigger | boolean | - | From config: tooltip: { |
| openOnFocus | Show when trigger get focused | boolean | - | From config: tooltip: { |
| openOnHover | Show when hover over the trigger | boolean | - | From config: tooltip: { |
| options | Dropdown options, unnecessary when default slot is used | DropdownOptions<unknown> | - | |
| override | Override existing theme classes completely | boolean | - | |
| position | Position of the dropdown relative to the trigger | "auto" | "bottom-left" | "bottom-right" | "bottom" | "left" | "right" | "top-left" | "top-right" | "top" | auto, top, bottom, left, right, top-right, top-left, bottom-left, bottom-right |
From config: dropdown: { |
| scrollable | Menu content will be scrollable | boolean | - | false |
| selectOnClose | Select current focused item when closed | boolean | - | From config: dropdown: { |
| selectOnFocus | Select current focused item when focused | boolean | - | From config: dropdown: { |
| selectable | Enables item selection | boolean | - | false |
| teleport | Append the component to another part of the DOM. Set true to append the component to the body.In addition, any CSS selector string or an actual DOM node can be used. |
boolean | object | string | - | From config: dropdown: { |
| triggerTag | Dropdown trigger tag name | DynamicComponent | - | From config: dropdown: { |
| Event name | Properties | Description |
|---|---|---|
| update:model-value | value unknown | unknown[] - updated modelValue prop |
modelValue prop two-way binding |
| update:active | value boolean - updated active prop |
active prop two-way binding |
| select | value unknown - selected value |
on select event - fired before update:modelValue |
| change | value unknown | unknown[] - selected value |
|
| open | event Event - native event |
on active state changes to true |
| close | event Event - native event |
on active state changes to false |
| scroll-start | the list inside the dropdown reached the start | |
| scroll-end | the list inside the dropdown reached it's end |
| Name | Description | Bindings |
|---|---|---|
| trigger | Override the trigger element, default is label prop | active boolean - dropdown active statevalue unknown | unknown[] - the selected valuetoggle (event: Event): void - toggle dropdown active state |
| before | Define extra o-dropdown-item components here, even if you have some options defined by prop |
toggle (): void - toggle dropdown active state |
| default | Define the dropdown items here | toggle (): void - toggle dropdown active state |
| group | Override the option group | group object - options group item |
| option | Override the label, default is label prop | option object - option item |
| empty | Define the content to show if the list is empty | toggle (): void - toggle dropdown active state |
| after | Define extra o-dropdown-item components here, even if you have some options defined by prop |
toggle (): void - toggle dropdown active state |
An option item used by the dropdown component.
<o-dropdown-item></o-dropdown-item>| Prop name | Description | Type | Values | Default |
|---|---|---|---|---|
| clickable | Item is clickable and emit an event | boolean | - | true |
| disabled | Item is disabled | boolean | - | false |
| hidden | Define whether the item is visible or not | boolean | - | false |
| label | Item label, unnecessary when default slot is used | string | - | |
| override | Override existing theme classes completely | boolean | - | |
| tag | Dropdown item tag name | DynamicComponent | - | |
| value | Item value (it will be used as the v-model of the wrapper component) - default is an uuid | string|number|object | - | useId() |
| Event name | Properties | Description |
|---|---|---|
| click | value unknown - value prop dataevent event - native event |
onclick event |
| Name | Description | Bindings |
|---|---|---|
| default | Override the label, default is label prop |
Current theme ➜ Oruga
| SASS Variable | Default |
|---|---|
| $dropdown-disabled-opacity | h.useVar("control-disabled-opacity") |
| $dropdown-menu-zindex | map.get(vars.$zindex, "dropdown") |
| $dropdown-menu-spacer | 0px |
| $dropdown-menu-padding | h.useVar("control-spacer") 0 |
| $dropdown-menu-box-shadow | 0 0.5em 1em -0.125em rgba(10, 10, 10, 0.1), 0 0 0 1px rgba(10, 10, 10, 0.02) |
| $dropdown-menu-background-color | h.useVar("control-background-color") |
| $dropdown-menu-border-color | h.useVar("control-border-color") |
| $dropdown-menu-border-style | solid |
| $dropdown-menu-border-width | h.useVar("control-border-width") |
| $dropdown-menu-border-radius | h.useVar("border-radius") |
| $dropdown-item-padding | 0.25rem 1rem |
| $dropdown-item-color | h.useVar("font-color") |
| $dropdown-item-font-size | h.useVar("font-size") |
| $dropdown-item-font-weight | h.useVar("font-weight") |
| $dropdown-item-line-height | h.useVar("line-height") |
| $dropdown-item-background-color | transparent |
| $dropdown-item-active-color | h.useVar("primary-invert") |
| $dropdown-item-active-background-color | h.useVar("primary") |
| $dropdown-item-hover-background-color | h.useVar("grey-lighter") |
| $dropdown-item-hover-color | h.useVar("font-color") |
| $dropdown-modal-zindex | map.get(vars.$zindex, "modal") |
| $dropdown-modal-max-height | min(50vh, calc(100vh - 160px)) |
| $dropdown-modal-max-width | min(50vw, calc(100vw - 160px)) |
| $dropdown-modal-min-width | min(80vw, 400px) |
| $dropdown-overlay-background-color | h.useVar( "overlay-background-color") |
| $dropdown-overlay-zindex | map.get(vars.$zindex, "overlay") |
See ➜ 📄 SCSS file
Current theme ➜ Bulma
| SASS Variable | Default |
|---|---|
| $dropdown-content-max-height | 200px |
| $dropdown-disabled-opacity | 0.5 |
| $dropdown-gap | 0px |
| $dropdown-z | 40 |
| $dropdown-mobile-breakpoint | iv.$desktop |
| $dropdown-background-background-color | hsla( #{css.getVar("scheme-h")}, #{css.getVar("scheme-s")}, #{css.getVar("scheme-invert-l")}, 0.86) |
| $dropdown-modal-width | 75% |
| $dropdown-modal-min-width | 25% |
| $dropdown-modal-max-width | calc(100vw - 40px) |
See ➜ 📄 SCSS file