Components/DropdownMenu
Universal Component

DropdownMenu

Compact menu surface built on Popover

This page was migrated by AI, please review carefully

Migration is complete, but please validate against source code and manual review.

DropdownMenu

TxDropdownMenu renders a compact action menu from a trigger slot. It is controlled with v-model and uses TxDropdownItem for selectable menu rows.

Basic Usage

Demo will load when visible.
<template>
  <TxDropdownMenu>
    <template #trigger>
      <TxButton>Menu</TxButton>
    </template>

    <TxDropdownItem>Open</TxDropdownItem>
    <TxDropdownItem danger>Delete</TxDropdownItem>
  </TxDropdownMenu>
</template>
Demo will load when visible.
<script setup lang="ts">
import { ref } from 'vue'

const open = ref(false)
</script>

<template>
  <div style="display: flex; align-items: center; gap: 10px;">
    <TxDropdownMenu v-model="open" :min-width="240" placement="bottom-start" :panel-padding="8">
      <template #trigger>
        <div
          style="display: inline-flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--tx-border-color); border-radius: 12px; user-select: none; cursor: pointer;"
        >
          <div style="font-weight: 600;">
            Repository
          </div>
          <div style="color: var(--tx-text-color-secondary); font-weight: 600;">
            main
          </div>
          <TxIcon name="chevron-down" style="opacity: 0.65;" />
        </div>
      </template>

      <TxDropdownItem arrow>
        GitHub
        <template #right>
          <span style="opacity: 0.72; display: inline-flex; align-items: center;">
            <i class="i-ri-external-link-line" style="font-size: 16px;" />
          </span>
        </template>
      </TxDropdownItem>
      <TxDropdownItem arrow>
        NPM
        <template #right>
          <span style="opacity: 0.72; display: inline-flex; align-items: center;">
            <i class="i-ri-external-link-line" style="font-size: 16px;" />
          </span>
        </template>
      </TxDropdownItem>
    </TxDropdownMenu>
  </div>
</template>

API

TxDropdownMenu Props

PropTypeDefaultDescription
modelValuebooleanfalseControls whether the dropdown is open.
placementDropdownPlacement'bottom-start'Positions the panel relative to the trigger.
offsetnumber6Distance in pixels between the trigger and panel.
closeOnSelectbooleantrueCloses the menu after an enabled item emits select.
durationnumber180Popover transition duration in milliseconds.
minWidthnumber220Minimum panel width in pixels.
maxHeightnumber420Maximum scrollable panel height in pixels.
unlimitedHeightbooleanfalseDisables the panel max-height constraint.
referenceClassBaseAnchorClassValue-Extra class value forwarded to the trigger anchor.
panelCardBaseAnchorPanelCardProps-Low-level card props forwarded to the popover panel.
panelVariant'solid' | 'dashed' | 'plain''solid'Visual border variant forwarded to the popover panel.
panelBackground'pure' | 'mask' | 'blur' | 'glass' | 'refraction''refraction'Background treatment forwarded to the popover panel.
panelShadow'none' | 'soft' | 'medium''soft'Shadow strength forwarded to the popover panel.
panelRadiusnumber18Panel corner radius in pixels.
panelPaddingnumber8Panel padding in pixels.

TxDropdownItem Props

PropTypeDefaultDescription
disabledbooleanfalsePrevents selection and renders the item as disabled.
dangerbooleanfalseApplies danger text styling for destructive actions.
arrowbooleanfalseShows a trailing chevron when no right slot is provided.

TxDropdownMenu Events

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

TxDropdownItem Events

EventParamsDescription
select-Emitted when an enabled item is clicked.