Files
heroui-vue/apps/docs/demos/dropdown-with-descriptions.vue
T
maoyingjie 06ddb6662a feat: migrate Menu and Dropdown with selection and submenus
Port HeroUI menu family and Dropdown from ce90ea3: Reka DropdownMenu base,
MenuKey[] selection with section owners, 17 official demos, dropdown docs
and B01 tests. Long-press stays demo-level; submenu close is level-scoped.
2026-10-24 20:43:04 +08:00

90 lines
2.8 KiB
Vue

<script setup lang="ts">
import {
IconDeviceFloppy,
IconFolderOpen,
IconPlus,
IconTrash,
} from "@tabler/icons-vue";
import {
DropdownRoot,
DropdownTrigger,
DropdownPopover,
DropdownMenu,
DropdownItem,
Button,
Label,
Description,
Kbd,
KbdAbbr,
KbdContent,
} from "@heroui-vue/components";
function onAction(key: string | number) {
console.log(`Selected: ${key}`);
}
</script>
<template>
<DropdownRoot>
<DropdownTrigger>
<Button aria-label="菜单" variant="secondary">操作</Button>
</DropdownTrigger>
<DropdownPopover>
<DropdownMenu @action="onAction">
<DropdownItem id="new-file" text-value="新建文件">
<div class="flex h-8 items-start justify-center pt-px">
<IconPlus class="size-4 shrink-0 text-muted" />
</div>
<div class="flex flex-col">
<Label>新建文件</Label>
<Description>创建新文件</Description>
</div>
<Kbd class="ms-auto" variant="light">
<KbdAbbr key-value="command" />
<KbdContent>N</KbdContent>
</Kbd>
</DropdownItem>
<DropdownItem id="open-file" text-value="打开文件">
<div class="flex h-8 items-start justify-center pt-px">
<IconFolderOpen class="size-4 shrink-0 text-muted" />
</div>
<div class="flex flex-col">
<Label>打开文件</Label>
<Description>打开已有文件</Description>
</div>
<Kbd class="ms-auto" variant="light">
<KbdAbbr key-value="command" />
<KbdContent>O</KbdContent>
</Kbd>
</DropdownItem>
<DropdownItem id="save-file" text-value="保存文件">
<div class="flex h-8 items-start justify-center pt-px">
<IconDeviceFloppy class="size-4 shrink-0 text-muted" />
</div>
<div class="flex flex-col">
<Label>保存文件</Label>
<Description>保存当前文件</Description>
</div>
<Kbd class="ms-auto" variant="light">
<KbdAbbr key-value="command" />
<KbdContent>S</KbdContent>
</Kbd>
</DropdownItem>
<DropdownItem id="delete-file" text-value="删除文件" variant="danger">
<div class="flex h-8 items-start justify-center pt-px">
<IconTrash class="size-4 shrink-0 text-danger" />
</div>
<div class="flex flex-col">
<Label>删除文件</Label>
<Description>移至废纸篓</Description>
</div>
<Kbd class="ms-auto" variant="light">
<KbdAbbr key-value="command" />
<KbdAbbr key-value="shift" />
<KbdContent>D</KbdContent>
</Kbd>
</DropdownItem>
</DropdownMenu>
</DropdownPopover>
</DropdownRoot>
</template>