# ContextMenu

> A menu that opens at the pointer on right-click, sharing DropdownMenu's item, submenu and keyboard behaviour but anchored to a virtual point instead of a trigger element.

- Package: `fancy-ui-react` (React 18/19 + Tailwind CSS v4)
- Category: Navigation
- Tags: menu, context-menu, right-click, compound, submenu, accessibility
- Dependencies: dropdown-menu
- Types: `ContextMenuProps`, `ContextMenuTriggerProps`, `ContextMenuContentProps`, `ContextMenuItemProps`, `ContextMenuSeparatorProps`, `ContextMenuLabelProps`, `ContextMenuSubProps`, `ContextMenuSubTriggerProps`, `ContextMenuSubContentProps`, `ContextMenuRootContext`, `MenuContext`, `SubContext`
- Docs: https://fancy-ui.rama.app/docs/components/context-menu
- Source: https://github.com/RamaHerbin/fancy-ui/tree/main/react/src/components/context-menu

## Import

```tsx
import { ContextMenu } from 'fancy-ui-react';
```

Setup (once per project): `npm install fancy-ui-react`, then put these lines in your main CSS file (the stylesheet import goes right after `@import "tailwindcss";`):

```css
@import "tailwindcss";
@import "fancy-ui-react/tailwind.css";
```

and import the component styles once in the app entry: `import "fancy-ui-react/styles.css";`. Full guide: https://fancy-ui.rama.app/llms.txt

The names below are the ones to write in React; when one differs from the Svelte name, the Svelte name follows in parentheses. `class` becomes `className`, a callback takes the name the React port declares (`onclick` becomes `onClick`), snippets become `ReactNode` props (render functions when they take arguments) and the default snippet is `children`. Divergences: https://github.com/RamaHerbin/fancy-ui/tree/main/react#divergences-from-the-svelte-api

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `open` | `boolean` | `false` | Whether the menu is open. Bindable |
| `onOpenChange` | `(open: boolean) => void` | — | Called whenever the menu opens or closes, however it happened |
| `side` | `"top" \| "bottom" \| "left" \| "right"` | `"bottom"` | Side of the pointer to place the menu on. Flips when it would overflow |
| `align` | `"start" \| "center" \| "end"` | `"start"` | Alignment along the pointer's cross axis |
| `offset` | `number` | `2` | Gap in pixels between the pointer and the menu |
| `loop` | `boolean` | `true` | Whether arrow-key navigation wraps at the ends |
| `sound` | `boolean` | `false` | Plays open/close on the menu and its submenus and select on an item, once the user has enabled sound |

## Node props

| Prop | Description |
| --- | --- |
| `children` | The ContextMenuTrigger and ContextMenuContent |

## Example

No React example is published for this component yet: start from the import above and the props table. The full examples are Svelte-only, on https://fancy-ui.rama.app/docs/components/context-menu.md.
