For AI agents: the complete documentation index is available at https://rickyshin93.github.io/tao-ui/zh/llms.txt, the full documentation bundle is available at https://rickyshin93.github.io/tao-ui/zh/llms-full.txt, and this page is available as Markdown at https://rickyshin93.github.io/tao-ui/zh/components/context-menu.md.
v0.0.57
  • 简体中文
  • ContextMenu

    导航@rockshin/tao-ui

    通过右键或长按为对象提供上下文操作菜单。

    何时使用

    对象或区域需要提供次要操作时使用 ContextMenu。

    推荐

    • 菜单项使用简短、动作导向的文案。
    • 关键操作必须提供其他可访问入口。

    避免

    • 不要把主要工作流只放进上下文菜单。

    代码演示

    基础用法

    Right-click this area
    TSX

    分组、禁用项与子菜单

    Right-click for grouped actions
    TSX

    可选择菜单项

    Current density: comfortable
    TSX

    分组与子菜单

    用分组和嵌套 children 组织操作,危险操作使用 danger。在区域内右键打开。

    Right-click here
    TSX

    菜单多选

    通过 selectedKeys 和 onSelect 保留选中状态,可用于视图选项。

    Right-click — 1 shown
    TSX

    禁用右键菜单

    disabled 停用自定义菜单;不要把关键操作只放在右键菜单里。

    Right-click here
    TSX

    API

    ContextMenu

    属性说明类型默认值
    childrenElement whose right-click (long-press on touch) opens the menu.ReactNode (必填)-
    disabled是否禁用boolean | undefined-
    classNameMerged onto the floating content.string | undefined-
    style节点样式CSSProperties | undefined-