# contextMenu

> Opens a ContextMenu's popover surface at the pointer position when its host receives a right-click, anchoring it with `@remix-run/ui/anchor`'s point-based positioning since no markup can anchor a floating surface to a pointer position.

```ts
import { contextMenu } from "@sdxc/ui/mixins";
```

Opens the popover surface identified by `id` at the pointer position on a
`contextmenu` event, or the host's bounding box from the keyboard, since a
`popover="auto"` surface already handles its own Escape/outside-click dismissal.
A pointer's menu opens on the release of the press that asked for it, so the surface
stays up until the next press rather than being dismissed by that same one.

## Signature

```ts
contextMenu(id: string, options?: AnchorOptions): MixinDescriptor<HTMLElement>
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `id` | `string` | `id` of the popover surface to open. |
| `options?` | `AnchorOptions` | Anchor placement and offsets forwarded to `@remix-run/ui/anchor`; placement defaults to `"bottom-start"`. Safe to omit — `contextMenu(id)` resets the runtime's trailing current-props argument back to an empty options object. |

## Examples

```tsx
<div id="row-1" mix={contextMenu("row-1-menu")}>Row 1</div>
<div id="row-1-menu" popover="auto" role="menu">...</div>
```
