On this page

Dropdown menu

Install, props and the parts Dropdown menu is built from.

Install

Run this in the app, after shadcn-vue init and the Beehexa theme (Button › Code):

npx shadcn-vue@latest add https://beehexa.design/r/dropdown-menu.json

The same registry item serves Menu button and Split button; installing it again adds the checkbox, radio, group and sub-menu parts.

Use

<script setup lang="ts">
import { ref } from 'vue'
import { Button } from '@/components/ui/button'
import {
  DropdownMenu, DropdownMenuContent, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuTrigger,
} from '@/components/ui/dropdown-menu'

const sort = ref('newest')
</script>

<template>
  <DropdownMenu>
    <DropdownMenuTrigger as-child>
      <Button variant="outline">Sort</Button>
    </DropdownMenuTrigger>
    <DropdownMenuContent>
      <DropdownMenuLabel>Sort orders by</DropdownMenuLabel>
      <DropdownMenuRadioGroup v-model="sort">
        <DropdownMenuRadioItem value="newest">Newest first</DropdownMenuRadioItem>
        <DropdownMenuRadioItem value="oldest">Oldest first</DropdownMenuRadioItem>
      </DropdownMenuRadioGroup>
    </DropdownMenuContent>
  </DropdownMenu>
</template>

Props

Part Prop Values Notes
DropdownMenuContent align, side, sideOffset Default start, bottom, 4 (space.overlay.offset)
DropdownMenuItem variant default, destructive Danger text and icon
DropdownMenuItem, DropdownMenuLabel, DropdownMenuSubTrigger inset boolean Lines the text up with items that have an icon
DropdownMenuItem disabled boolean Skipped by the arrow keys
DropdownMenuItem @select event Runs the action. @select.prevent keeps the menu open
DropdownMenuCheckboxItem v-model boolean On or off
DropdownMenuRadioGroup v-model string The chosen DropdownMenuRadioItem value
DropdownMenuCheckboxItem, DropdownMenuRadioItem slot indicator-icon Replaces the check

Built on

The reka-ui DropdownMenu, with the shadcn-vue DropdownMenu API. reka-ui gives the menu roles, aria-checked, focus handling, typeahead and sub-menu keys. Beehexa adds the styles. Sub-menus open in a portal, so a scrolling menu does not cut them off.