# Context menu

Host: Base UI. Path: transitions. Preset: `scale-fade`. Built against [@base-ui/react 1.5.0](https://www.npmjs.com/package/@base-ui/react/v/1.5.0).

Shares its parts with Menu, and therefore its rule.

The page this file mirrors mounts the component twice, once with the attribute and once without, so the only difference between the two is the library.

Upstream documentation: [Base UI documentation](https://base-ui.com/react/components/context-menu)

The same component in other hosts: [Radix UI](/radix/context-menu.md).

## Where the attribute goes

The parts this demo composes, and the value each one carries. Everything inside an animated part is that part's content, so the tree stops there.

```text
ContextMenu.Root
  ContextMenu.Trigger
  ContextMenu.Portal
    ContextMenu.Positioner
      ContextMenu.Popup  data-motion="scale-fade"
```

## How the match works

| Step | Value |
| --- | --- |
| host writes | `data-ending-style` |
| easeful matches | `[data-motion~="scale-fade"][data-ending-style]` |
| what runs | `transition: opacity, scale 150ms` |
| you write | `<ContextMenu.Popup data-motion="scale-fade" />` |

## Every value that works here

Every value the manifest allows on this host, single presets and the pairs that compose. The first is what this component ships with. Both stages are the same component, so anything that changes between them is the attribute.

| Value | Link |
| --- | --- |
| `scale-fade` | the default |
| `fade` | [fade](/base-ui/context-menu#motion=fade) |
| `slide-up` | [slide-up](/base-ui/context-menu#motion=slide-up) |
| `fade slide-up` | [fade slide-up](/base-ui/context-menu#motion=fade%20slide-up) |
| `scale-fade slide-up` | [scale-fade slide-up](/base-ui/context-menu#motion=scale-fade%20slide-up) |

## Source

`apps/docs/components/demos/base-ui/context-menu.tsx`

```tsx
"use client"

import { ContextMenu } from "@base-ui/react/context-menu"
import type { DemoProps } from "@/components/demos/props"

export function BaseUiContextMenu({ motion }: DemoProps) {
  return (
    <ContextMenu.Root>
      <ContextMenu.Trigger className="dropzone">right click here</ContextMenu.Trigger>
      <ContextMenu.Portal>
        <ContextMenu.Positioner collisionPadding={16}>
          <ContextMenu.Popup className="menu" data-motion={motion}>
            <ContextMenu.Item className="menu__item">Rename</ContextMenu.Item>
            <ContextMenu.Item className="menu__item">Duplicate</ContextMenu.Item>
            <ContextMenu.Item className="menu__item">Archive</ContextMenu.Item>
          </ContextMenu.Popup>
        </ContextMenu.Positioner>
      </ContextMenu.Portal>
    </ContextMenu.Root>
  )
}
```
