Files
heroui-vue/apps/docs/demos/dropdown-controlled.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

49 lines
1.4 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { ref } from "vue";
import {
DropdownRoot,
DropdownTrigger,
DropdownPopover,
DropdownMenu,
DropdownItem,
DropdownItemIndicator,
Button,
Label,
} from "@heroui-vue/components";
import type { MenuKey } from "@heroui-vue/components";
const selected = ref<MenuKey[]>(["bold"]);
</script>
<template>
<div class="flex min-w-sm flex-col items-center justify-center gap-4">
<p class="text-sm text-muted">
已选:{{ selected.length > 0 ? selected.join("、") : "无" }}
</p>
<DropdownRoot>
<DropdownTrigger>
<Button aria-label="菜单" variant="secondary">操作</Button>
</DropdownTrigger>
<DropdownPopover>
<DropdownMenu
:selected-keys="selected"
selection-mode="multiple"
@update:selected-keys="(keys: MenuKey[]) => (selected = keys)"
>
<DropdownItem id="bold" text-value="粗体">
<Label>粗体</Label>
<DropdownItemIndicator />
</DropdownItem>
<DropdownItem id="italic" text-value="斜体">
<Label>斜体</Label>
<DropdownItemIndicator />
</DropdownItem>
<DropdownItem id="underline" text-value="下划线">
<Label>下划线</Label>
<DropdownItemIndicator />
</DropdownItem>
</DropdownMenu>
</DropdownPopover>
</DropdownRoot>
</div>
</template>