Vibary.ai
← Vibe Coding

Context Menu Open

The menu grows out of the point you pressed, from whichever corner keeps it on the surface.

navigationminimalfuturisticinteraction · finite · advanced · ~0.3s
Interactive · click to play
Variant

The animated component in this preview is rendered from the canonical file shown here. The surrounding demo shell only provides context and is not part of the copied code.

464 lines · react + motion only
import {
  Fragment,
  useEffect,
  useRef,
  useState,
  type MouseEvent as ReactMouseEvent,
} from "react";
import { AnimatePresence, motion, useReducedMotion } from "motion/react";

About this pattern

A right-click menu whose origin is the press itself. The corner is chosen before anything animates: the open measures the pointer against the surface, decides whether the panel should extend right or left, down or up, and sets the transform origin to match — so near an edge the menu grows back toward the middle instead of starting to hang off and correcting itself, which is the visible mistake in most implementations. Growth is a few percent and no more, because the panel is text and a menu that scales up from nothing resizes every glyph in it on the way; the rows themselves only fade. Dismissal is quicker than the open, a catcher rather than a scrim takes the next press, and the row the menu belongs to stays marked so there is never a question of what it is acting on.

File row actionsCanvas right-click menuTable row commandsEditor selection menu