easeul

Radix UIKeyframes

Context menu

Opens from a pointer position rather than an element, and still needs no special case.

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.

withoutno attribute
right click here
with easefuldata-motion="scale-fade"
right click here
host writes

data-state, data-side

easeful matches

[data-motion~="scale-fade"][data-state="closed"]

what runs

animation: motion-exit 150ms

you write

<ContextMenu.Content data-motion="scale-fade" />

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.

  1. ContextMenu.Root
  2. ContextMenu.Trigger
  3. ContextMenu.Portal
  4. ContextMenu.Contentdata-motion="scale-fade"

Source

"use client"

import { ContextMenu } from "radix-ui"
import type { DemoProps } from "@/components/demos/props"

export function RadixContextMenu({ motion }: DemoProps) {
  return (
    <ContextMenu.Root>
      <ContextMenu.Trigger className="dropzone">right click here</ContextMenu.Trigger>
      <ContextMenu.Portal>
        <ContextMenu.Content className="menu" collisionPadding={16} 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.Content>
      </ContextMenu.Portal>
    </ContextMenu.Root>
  )
}
The whole file, read from disk at build time. Both copies above render from it, and the motion prop is the only difference between them.