Components/DropdownMenu

DropdownMenu

A menu of short commands that opens from a trigger.

VerifiedSince 0.3.4

Usage

Basic

A selection blinks to confirm, then closes the menu; an item with activation-feedback="false" runs at once.

Loading demo...

TxDropdownSubmenu nests child panels to any depth; hovering the trigger row expands one.

Loading demo...

The trigger slot takes any element; the right slot replaces an item's trailing arrow.

Loading demo...

Dashboard Navigation

TxTabs hold the top-level sections; light actions go in TxDropdownMenu, short notes in TxPopover, and dense settings in TxDrawer.

Loading demo...

Best Practices

  • Keep it to short commands. For paragraphs, forms, or multi-step interaction, use TxPopover, TxDrawer, or TxContextMenuPanel.
  • Use danger only for destructive commands, and group them apart from neutral ones as the list grows.
  • Use arrow only on navigation or submenu rows; put external-link icons, shortcuts, and status badges in the right slot.
  • Set closeOnSelect=false only on rows that open another surface or start a multi-step flow. Turn off activationFeedback only when the host gives stronger feedback or needs a synchronous callback.
  • Set initialFocus="none" only when the host places focus itself after opening, such as on a search field in the panel; otherwise keyboard users need an extra arrow press to reach the list.

API Reference

TxDropdownMenu

Props

PropTypeDefaultDescription
modelValuebooleanundefinedOpen state (v-model); omit it to leave the menu uncontrolled.
trigger'click' | 'hover''click'Trigger mode; TxPopover handles hover timing and mutual exclusion.
placementDropdownPlacement'bottom-start'Panel position relative to the trigger.
offsetnumber6Distance between the trigger and the panel, in px.
closeOnSelectbooleantrueCloses the menu after an enabled item emits select.
activationFeedbackbooleantrueClears, then confirms the highlight for 90 ms each before closing; skipped under reduced motion.
initialFocus'first-item' | 'none''first-item'Where focus lands on open; 'none' leaves it for the host to place.
animationBaseAnchorAnimationOptions{}Panel animation; an empty object uses BaseAnchor's default.
minWidthnumber220Minimum panel width in px; the maximum is fixed at 360px.
maxHeightnumber420Maximum panel height in px; taller content scrolls.
unlimitedHeightbooleanfalseRemoves the panel's height limit.
referenceClassBaseAnchorClassValue-Extra class on the trigger anchor.
panelCardBaseAnchorPanelCardProps-Card props forwarded to the panel.
panelVariant'solid' | 'dashed' | 'plain''solid'Panel border style.
panelBackground'pure' | 'mask' | 'blur' | 'glass' | 'refraction''refraction'Panel background effect.
panelShadow'none' | 'soft' | 'medium''soft'Panel shadow.
panelRadiusnumber18Panel corner radius in px.
panelPaddingnumber8Panel padding in px.

Events

EventParamsDescription
update:modelValue(value: boolean)Fires when the menu requests an open-state change.
open-Fires when the menu requests opening.
close-Fires when the menu requests closing.

Slots

SlotPropsDescription
trigger-Trigger content, used as the Popover reference.
default-Menu rows, usually TxDropdownItem.

TxDropdownItem

Props

PropTypeDefaultDescription
disabledbooleanfalsePrevents selection; the menu stays open.
dangerbooleanfalseDanger text styling.
arrowbooleanfalseShows a trailing arrow when there is no right slot.
closeOnSelectbooleanundefinedPer-item override of the menu's closeOnSelect.
activationFeedbackbooleanundefinedPer-item override of the menu's confirmation feedback.

Events

EventParamsDescription
select-Fires on selection, without a payload; a closing item with feedback fires after the 180 ms confirmation.

Slots

SlotPropsDescription
default-Main label.
right-Replaces the trailing arrow drawn by arrow.

TxDropdownSubmenu

Props

PropTypeDefaultDescription
disabledbooleanfalseDisables the trigger row; the child panel no longer opens.
placementDropdownPlacement'right-start'Child panel position relative to the trigger row.
offsetnumber4Distance between the trigger row and the child panel, in px.
widthnumber0Fixed child panel width; 0 sizes to content, bounded by minWidth.
minWidthnumber160Minimum child panel width in px.
maxHeightnumber420Maximum child panel height in px; taller content scrolls.
unlimitedHeightbooleanfalseRemoves the child panel's height limit.
animationBaseAnchorAnimationOptions{}Child panel animation.
panelCardBaseAnchorPanelCardProps-Card props forwarded to the child panel.
panelVariant'solid' | 'dashed' | 'plain''solid'Child panel border style.
panelBackground'pure' | 'mask' | 'blur' | 'glass' | 'refraction''refraction'Child panel background effect.
panelShadow'none' | 'soft' | 'medium''soft'Child panel shadow.
panelRadiusnumber14Child panel corner radius in px.
panelPaddingnumber6Child panel padding in px.

Slots

SlotPropsDescription
default-Trigger row label.
right-Trailing info on the trigger row, before the arrow.
menu-Child panel content; may nest another TxDropdownSubmenu.

Overview

  • It wraps TxPopover, so placement, height limits, panel card props, and animation follow the same anchor behavior.
  • A closing selection first clears the highlight, confirms with the TxCardItem active state, then emits select and closes; other selections emit at once. Disabled items neither select nor close.
  • The panel is role="menu" and items are role="menuitem". Opening focuses the first enabled item unless initialFocus="none".
  • Keyboard: ArrowDown / ArrowUp move with wraparound and enter the list from a search field; Home / End jump to the ends, except inside an input, textarea, or contenteditable, where they move the caret.
  • Submenus: ArrowRight / Enter on the trigger row expand and focus the first item, ArrowLeft in the child collapses it. Child items close the whole chain per the root's closeOnSelect; clicks inside a child aren't outside clicks, and closing a parent closes its children.
  • A hover bridge covers the 4px gap between parent and child panels. Sibling submenu rows crossed on a diagonal don't expand; resting on one for about 100 ms switches to it.

Technologies

  • Activation feedback runs on packages/tuffex/packages/utils/menu-activation-feedback.ts, shared with ContextMenu.
  • Source: packages/tuffex/packages/components/src/dropdown-menu/.
查看源码
packages/tuffex/packages/components/src/dropdown-menu/index.ts