Dropdown

A menu that opens from a trigger and holds a list of choices or actions.

Refined portVue source: WildDropdown.vueStorybook story: Dropdowns/DropdownReact component: WDropdown, WDropdownMenu

Try it

Pick an item, then reopen the menu from the keyboard and use the arrow keys.

Content
Align
Min width
Choice descriptions
Disabled item
<WildDropdown v-model:open="open" :min-width="240">
  <template #trigger="{ toggle }">
    <WildButton variant="borders" size="sm" icon="chevron-down" @click="toggle">{{ range }}</WildButton>
  </template>
  <WildDropdownItem label="Last 7 days" :selected="range === 'Last 7 days'" @click="range = 'Last 7 days'" />
  <WildDropdownItem label="Last 30 days" :selected="range === 'Last 30 days'" @click="range = 'Last 30 days'" />
  <WildDropdownItem label="Last 90 days" :selected="range === 'Last 90 days'" @click="range = 'Last 90 days'" />
  <WildDropdownItem label="This month" :selected="range === 'This month'" @click="range = 'This month'" />
</WildDropdown>

When to use

  • Use it to switch a view between a few options, such as a time range.
  • Use it to group actions on a page or a record behind one labelled button.
Don’t use it
  • To choose a value in a form. Use Select.
  • For a filter in a filter bar. Use Dropdown pill.
  • For row actions in a table. Use Icon menu.
  • For two or three options always on show. Use Segmented.

States

A chosen item is filled blue with a tick. Destructive items are red, and disabled items turn grey but keep their place.

Last 7 days
Last 30 days
Last 90 days
This month
choices
Edit site
Download
Delete site
actions
<WildDropdownItem label="Last 30 days" selected />
<WildDropdownItem label="This month" disabled />
<WildDropdownItem label="Delete site" icon="trash" variant="destructive" />

Content

  • Start actions with a verb, and name the object: Edit site, Delete site.
  • Keep labels to one line. Put a consequence in the description.
  • Put a destructive action last, and confirm it with a confirm dialog.
  • Disable an item instead of hiding it, so the list doesn’t shift between openings.

Accessibility

The trigger announces a menu and whether it’s open. Choices are read as radio items with their checked state.

KeyWhat it does
Enter / SpaceOn the trigger, opens on the chosen item. In the menu, picks and closes.
Down / UpOn the trigger, opens on the first or last item. In the menu, moves and wraps.
Home / EndMoves to the first or last item.
A letterMoves to the next item starting with it.
EscapeCloses and returns focus to the trigger.
TabCloses the menu and moves on.

Props

PropTypeDefaultDescription
openbooleanfalseOpen state, bound with v-model:open.
align'start' | 'end''start'Trigger edge the menu aligns to.
placement'bottom' | 'top''bottom'Preferred side; flips when there isn’t room.
minWidthnumber200Narrowest width in px; grows to fit.
maxHeightnumber400Height in px past which it scrolls.
matchTriggerWidthbooleanfalseSets the menu to the trigger’s width.
fullWidthbooleanfalseContainer spans its parent.
closeOnClickOutsidebooleantrueCloses on a press outside.
closeOnEscapebooleantrueCloses on Escape.
closeOnScrollbooleantrueCloses when the page scrolls.
repositionOnScrollbooleanfalseWith closeOnScroll off, follows the trigger instead of closing.
#triggerslot { open, toggle }—The button that opens the menu.
Item labelstring—The item’s text.
Item valuestring | number—Sent with @click.
Item selectedbooleanfalseFills the chosen item and adds a tick.
Item showCheckmarkbooleantrueShows the selected item’s tick.
Item disabledbooleanfalseGreys the item out and blocks it; arrow keys skip it.
Item iconstring—Icon name, shown before the label.
Item variant'default' | 'destructive''default'Destructive turns the item red.
Item descriptionstring—A second line under the label.
Item @click(value) => void—Fires with value when picked.

Tokens

TokenValueWhere it lands
--global-neutral-grey-500#E6E6E6Menu border.
--shadow-dropdown0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04)Menu elevation.
--radius-lg8pxMenu corners.
--global-cool-grey-1200#24262BItem label.
--global-cool-grey-900#595E6AItem icon and description.
--global-neutral-grey-300#F1F1F1Item hover.
--global-blue-1000#1877F2Chosen item fill and focus ring.
--global-blue-1100#0C296AChosen item fill on hover.
--color-white#FFFFFFChosen item label and tick.
--global-red-900#BC1C1CDestructive label.
--global-red-100#FEEBEBDestructive item hover.
--global-neutral-grey-200#F5F5F5Chosen item fill when disabled.
--global-neutral-grey-800#ADACB0Disabled label, icon and tick.