components/menu
내비게이션 · 37 / 64

Menu

ui.widgets.Menu

단축키 힌트가 있는 컨텍스트 동작 목록.

BEHAVIOR CONTRACT

trigger, portal, separator, danger item, 바깥 클릭 dismiss, Escape를 한 세트로 구현합니다.

RECORDED INTERACTION

harness가 Actions 메뉴를 열어 Cut / Copy / Delete를 보여 줍니다.

examples/storybook/stories.zig:2335
// ── Menu(trigger+popover:item 在弹层里,story 给 trigger 加按钮,e2e 点开验 item)──
pub fn buildMenu(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 menu"));
    const items = [_]W.MenuItem{
        .{ .id = "cut", .label_text = "Cut", .shortcut = "⌘X" },
        .{ .id = "copy", .label_text = "Copy", .shortcut = "⌘C" },
        .{ .id = "sep", .kind = .separator },
        .{ .id = "del", .label_text = "Delete", .danger = true },
    };
    const m = try W.Menu(.{ .items = &items }).mount(scope, cx);
    // 给 trigger 放一个有标签的按钮,让 story 可见可点
    try m.trigger.appendChild(a, try W.Button(.{ .label = "Actions ▾", .variant = .secondary }).mount(scope, cx));
    m.wrapper.meta.ownership.meta.test_id = "story.menu.trigger";
    try c.appendChild(a, m.wrapper);
    return c;
}
GitHub에서 소스 보기examples/storybook/stories.zig:2335

Storybook에 있는 이 story의 원본 코드입니다(zenit 5f9add5+wip 2026-09-30). W는 ui.widgets이며, col / row / label은 Storybook 내부의 작은 레이아웃 헬퍼입니다.

zenit · 이중 라이선스오픈 소스 프로젝트는 GPL-3.0-only로 무료 사용할 수 있으며, 비공개 소스나 상용 제품에는 상용 라이선스가 필요합니다.작성자 연락처: zongyi.xzy#gmail.com (#을 @로 바꾸세요)zenit 5f9add5+wip 2026-09-30