Context Menu

沿用菜单家族的菜单项、子菜单和键盘操作,在需要的位置打开:右键点击时出现在指针处,长按时出现在手指下,也可用上下文菜单键或 Shift+F10 打开。

可用框架
  • Angular: 可用
  • Vue: 可用
  • React: 可用
  • React Native: 可用

用法

Right-click or long-press here

导入

ts
import {
  SoneContextMenuTriggerDirective,
} from "@surface-one/angular/context-menu";

API 参考

SoneContextMenuTriggerDirective指令

`[soneContextMenuTrigger]` — the area that opens a `[soneMenu]` where it is asked for (spartan/ui `brnContextMenuTrigger`, Radix ContextMenu): a right click opens it at the pointer, a long press at the finger, and the ContextMenu key or Shift+F10 at the area on its first item. The menu is the menu family's: its items, groups, check / radio items, submenus, Arrow keys, Home / End, typeahead, and it closes on activation, Escape, Tab or a click outside, giving focus back to the area. Make the area focusable (`tabindex="0"`) so the keyboard can reach it.

选择器
[soneContextMenuTrigger]
导出为
soneContextMenuTrigger
输入
名称类型 默认值
side

The side of the trigger the panel opens on; it flips when that side lacks room.

FloatingSide"bottom"
align

Alignment along the trigger's edge.

FloatingAlign"start"
offset

Gap between the trigger and the panel, in px.

number4
open双向

Shown or not — `[(open)]`.

booleanfalse
keepOpenOnOutsideClick

Keep the panel open on a click outside it (Escape still closes it).

booleanfalse
soneMenuTriggerSoneOverlayContent | nullnull
soneContextMenuTriggerSoneOverlayContent | nullnull
disabled

Leave the browser's own context menu alone.

booleanfalse