Context Menu
Los elementos, submenús y teclas de la familia de menús, abiertos donde se piden: con clic derecho junto al puntero, con una pulsación larga bajo el dedo o con la tecla de menú contextual y Mayús+F10.
Angular: disponible Vue: disponible React: disponible React Native: disponible
Uso
<div class="demo-row" style="align-items: flex-start; min-height: 20rem">
<div
[soneContextMenuTrigger]="menu"
tabindex="0"
style="display: grid; place-items: center; width: 18rem; height: 9rem; border: var(--border-width-thin) dashed var(--border); border-radius: var(--radius-lg); color: var(--text-secondary); font-size: var(--font-size-sm)"
>
Right-click or long-press here
</div>
<ng-template #menu>
<div soneMenu aria-label="Page actions" style="width: 14rem">
<button soneMenuItem type="button">Back <kbd soneMenuShortcut>⌘[</kbd></button>
<button soneMenuItem type="button" disabled>Forward <kbd soneMenuShortcut>⌘]</kbd></button>
<button soneMenuItem type="button">Reload <kbd soneMenuShortcut>⌘R</kbd></button>
<div soneMenuSeparator></div>
<button soneMenuCheckboxItem type="button" [checked]="bookmarks()" (click)="bookmarks.set(!bookmarks())">
Show bookmarks
</button>
<div soneMenuSeparator></div>
<button soneMenuItem variant="destructive" type="button">Delete page</button>
</div>
</ng-template>
</div>Importación
import {
SoneContextMenuTriggerDirective,
} from "@surface-one/angular/context-menu";Referencia de la API
SoneContextMenuTriggerDirectiveDirectiva
`[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.
| Nombre | Tipo | Predeterminado |
|---|---|---|
sideThe side of the trigger the panel opens on; it flips when that side lacks room. | FloatingSide | "bottom" |
alignAlignment along the trigger's edge. | FloatingAlign | "start" |
offsetGap between the trigger and the panel, in px. | number | 4 |
openbidireccionalShown or not — `[(open)]`. | boolean | false |
keepOpenOnOutsideClickKeep the panel open on a click outside it (Escape still closes it). | boolean | false |
soneMenuTrigger | SoneOverlayContent | null | null |
soneContextMenuTrigger | SoneOverlayContent | null | null |
disabledLeave the browser's own context menu alone. | boolean | false |