---
title: "DropdownMenu-Komponente — zenit Zig UI"
description: "Eine Reihe von Befehlen, die sich über einen Button öffnet. Eintragsarten, Tastenkürzel, Auswahl-Callbacks, Positionierung und Schließen werden gemeinsam…"
url: https://zenit.z.express/de/components/dropdown
language: de
alternate_en: https://zenit.z.express/components/dropdown.md
alternate_zh: https://zenit.z.express/zh/components/dropdown.md
alternate_es: https://zenit.z.express/es/components/dropdown.md
alternate_ja: https://zenit.z.express/ja/components/dropdown.md
alternate_ko: https://zenit.z.express/ko/components/dropdown.md
alternate_fr: https://zenit.z.express/fr/components/dropdown.md
project: zenit v0.1.0-alpha (Zig 0.15.2, macOS)
source: https://github.com/version-next/zenit
---

# DropdownMenu

`ui.widgets.DropdownMenu`

Eine Reihe von Befehlen, die sich über einen Button öffnet.

[Video](https://zenit.z.express/media/stories/dropdown.mp4?v=00c4ad4c9c)

**BEHAVIOR CONTRACT**

Eintragsarten, Tastenkürzel, Auswahl-Callbacks, Positionierung und Schließen werden gemeinsam verwaltet.

**RECORDED INTERACTION**

Der Harness öffnet das Menü File: New / Open / Save.

`examples/storybook/stories.zig:2354`

```zig
// ── DropdownMenu（同 Menu：trigger+popover）──
pub fn buildDropdownMenu(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
    const a = cx.allocator;
    const c = try col(cx, 8);
    try c.appendChild(a, try label(cx, "Click the trigger to open the dropdown"));
    const items = [_]W.DropdownItem{
        .{ .id = "new", .label_text = "New File" },
        .{ .id = "open", .label_text = "Open…" },
        .{ .id = "sep", .kind = .separator },
        .{ .id = "save", .label_text = "Save" },
    };
    const dm = try W.DropdownMenu(.{ .items = &items }).mount(scope, cx);
    try dm.trigger.appendChild(a, try W.Button(.{ .label = "File ▾", .variant = .secondary }).mount(scope, cx));
    dm.wrapper.meta.ownership.meta.test_id = "story.dropdown.trigger";
    try c.appendChild(a, dm.wrapper);
    return c;
}
```

[Quellcode auf GitHub ansehenexamples/storybook/stories.zig:2354](https://github.com/version-next/zenit/blob/HEAD/examples/storybook/stories.zig#L2354)

Der unveränderte Quellcode der Story aus dem Storybook (zenit 5f9add5+wip 2026-09-30). `W` steht für `ui.widgets`; `col` / `row` / `label` sind kleine Layout-Helfer des Storybooks.

### DropdownMenuProps

`ui.widgets.DropdownMenu`

[src/ui/components/dropdown\_menu/mod.zig:69](https://github.com/version-next/zenit/blob/HEAD/src/ui/components/dropdown_menu/mod.zig#L69)

```zig
fn DropdownMenu(props: DropdownMenuProps) DropdownMenuBuilder
```

| Feld | Typ | Standard | Beschreibung |
| --- | --- | --- | --- |
| `items` | `[]const DropdownItem` | `&.{}` | 菜单项列表. mount copies the item records and their string fields, so callers may pass a function-local array. Handler contexts still follow the normal Scope lifetime contract. |
| `width` | `f32` | `220` | 面板宽度 |
| `position` | `popover_mod.PopoverPosition` | `.bottom_start` | 弹出位置 |
| `max_height` | `?f32` | `null` | 可选的菜单最大高度。设置后复用 Popover 的原生 fit\_or\_scroll/ScrollArea。 |

### DropdownMenuResult

`ui.widgets.DropdownMenu`

[src/ui/components/dropdown\_menu/mod.zig:83](https://github.com/version-next/zenit/blob/HEAD/src/ui/components/dropdown_menu/mod.zig#L83)

| Feld | Typ | Standard | Beschreibung |
| --- | --- | --- | --- |
| `wrapper` | `*Node` | — | 外层包裹节点 |
| `trigger` | `*Node` | — | trigger 插槽（调用方在此插入触发元素） |
| `state` | `*DropdownMenuState` | — | 内部状态（可用于外部控制） |
