LayerwiseLayerwise
  • Features
  • Pricing
  • Templates
  • Docs
DownloadDownload
FeaturesPricingTemplatesDocsAI Website BuilderVibe CodingPersonal Software
DownloadDownload
  1. Glossary
  2. /
  3. Components

Context menu

Also called right-click menu or shortcut menu

A menu of actions for one item that opens at the pointer when you right-click it, or long-press it on a touch screen.

import { ContextMenu } from '@base-ui/react/context-menu';

const FILES = ['Q3 report.pdf', 'Brand guidelines.fig', 'Launch plan.docx'];
const ACTIONS = ['Open', 'Rename', 'Duplicate'];
const item =
  'cursor-default rounded-lg px-3 py-2 text-sm outline-none select-none data-highlighted:bg-muted';

// A shortcut, not the only path: offer the same actions from a visible ⋯ button too.
export function FileList({
  onAction
}: {
  onAction: (action: string, file: string) => void;
}) {
  return (
    <ul className='w-80 divide-y rounded-xl border'>
      {FILES.map((file) => (
        <ContextMenu.Root key={file}>
          {/* Opens at the pointer on right-click, or after a long press on touch. */}
          <ContextMenu.Trigger
            render={<li />}
            className='px-4 py-3 text-sm select-none data-popup-open:bg-blue-500/10'
          >
            {file}
          </ContextMenu.Trigger>
          <ContextMenu.Portal>
            {/* The positioner shifts the menu to keep it inside the viewport. */}
            <ContextMenu.Positioner>
              <ContextMenu.Popup className='min-w-44 rounded-xl border bg-background p-1 shadow-lg outline-none transition-opacity duration-100 data-ending-style:opacity-0'>
                {ACTIONS.map((action) => (
                  <ContextMenu.Item
                    key={action}
                    className={item}
                    onClick={() => onAction(action, file)}
                  >
                    {action}
                  </ContextMenu.Item>
                ))}
                <ContextMenu.Separator className='my-1 h-px bg-border' />
                <ContextMenu.Item
                  className={`${item} text-red-600 data-highlighted:bg-red-500/10`}
                  onClick={() => onAction('Delete', file)}
                >
                  Delete
                </ContextMenu.Item>
              </ContextMenu.Popup>
            </ContextMenu.Positioner>
          </ContextMenu.Portal>
        </ContextMenu.Root>
      ))}
    </ul>
  );
}
Add a right-click menu to each file row with Open, Rename, Duplicate, a separator, and a red Delete. Open it at the pointer, shift it so it stays inside the viewport, highlight the row while the menu is open, and support arrow keys, Enter, and Escape. On touch devices, open it after a 500ms long press, and offer the same actions from a ⋯ button on each row.

Paste into Layerwise or any AI coding tool.

What is Context menu?

A context menu appears exactly where you right-click and lists actions for the thing under the pointer: open, rename, duplicate, or delete a file. Because the actions match what you clicked, it is a fast shortcut for people who already know where to look.

It belongs in apps people spend a lot of time in, like file browsers, editors, and design tools. Treat it as a shortcut and keep every action in it reachable from a visible button or menu as well, since many people never think to right-click and touch screens need a long press.

Open it instantly at the pointer, shift it so it stays on screen near the edges, highlight the item it belongs to, and close it on Escape or a click elsewhere. Calling preventDefault() in the contextmenu event replaces the browser's own menu, so do that only on elements that offer their own.

Often confused with

Dropdown menu
A dropdown menu opens from a visible button. A context menu is hidden until you right-click or long-press, and it opens at the pointer.

Related terms

All terms

Dropdown menu

A list of actions that drops down from a button when you click it, then closes as soon as you pick one.

Command palette

A search box that opens with a shortcut like ⌘K and lets you find and run any command or page by typing a few letters.

Keyboard shortcut

A key combination that runs an action directly, like ⌘S to save or ⌘K to open search, so frequent users can skip the mouse.

Affordance

The visual cues that tell people what they can do with an element, like a raised button that looks pressable or a grip that says "drag me".

Build it with Layerwise

Describe your app, watch it run in a live preview, and publish it with a database, storage, and sign-in built in.

DownloadDownloadRead the docs
LayerwiseLayerwise

Build full-stack web apps in minutes with AI.

Product

  • Features
  • Pricing
  • Download
  • Templates

Solutions

  • AI Website Builder
  • Vibe Coding
  • Personal Software

Resources

  • Documentation
  • Changelog
  • Blog
  • Vibe Coding Glossary
  • llms.txt
  • llms-full.txt

Company

  • About
  • Contact

Legal

  • Privacy
  • Analytics Privacy
  • Terms
  • Security
  • Abuse

© 2026 Layerwise. All rights reserved.

Entrances & exits

  • Fade in
  • Slide in
  • Scale in
  • Pop in
  • Blur in
  • Reveal animation
  • Enter and exit animations

Timing & sequencing

  • Duration
  • Delay
  • Keyframes
  • Tweening
  • Stagger
  • Orchestration
  • Fill mode
  • Stepped animation
  • Looping animation
  • Yoyo animation

Easing

  • Easing
  • Linear easing
  • Ease-in
  • Ease-out
  • Ease-in-out
  • Cubic-bezier
  • Asymmetric easing
  • Overshoot easing

Springs & physics

  • Spring animation
  • Stiffness
  • Damping
  • Mass
  • Bounce
  • Velocity
  • Momentum
  • Interruptible animation
  • Rubber-banding

Transforms

  • Translate
  • Scale
  • Rotate
  • Skew
  • 3D flip
  • Perspective
  • Transform origin
  • Origin-aware animation

State transitions

  • Crossfade
  • Morph
  • Shared element transition
  • Layout animation
  • Height auto animation
  • Direction-aware transition
  • Continuity transition
  • Page transition
  • View Transitions API

Scroll effects

  • Scroll reveal
  • Scroll-driven animation
  • Parallax scrolling
  • Scrollytelling
  • Scroll pinning
  • Horizontal scroll section
  • Scroll progress bar
  • Scroll snap
  • Smooth scrolling

Interaction feedback

  • Hover effect
  • Press feedback
  • Ripple effect
  • Shake animation
  • Hold to confirm
  • Drag gesture
  • Drag to reorder
  • Swipe to dismiss
  • Pull to refresh
  • Magnetic button
  • Custom cursor
  • 3D tilt card
  • Spotlight card

Text effects

  • Typewriter effect
  • Text scramble
  • Split text animation
  • Text morph
  • Rotating words
  • Gradient text
  • Shimmer text
  • Number ticker
  • Tabular numbers
  • Underline animation

Loops & ambient motion

  • Marquee
  • Pulse animation
  • Float animation
  • Orbit animation
  • Idle animation
  • Particle background
  • Border beam
  • Confetti
  • Animated gradient

Visual effects

  • Blur
  • Clip-path
  • Mask
  • Before/after slider
  • SVG line drawing
  • Lottie animation

Motion principles

  • Purposeful animation
  • Anticipation
  • Follow-through
  • Squash and stretch
  • Perceived performance
  • Frequency of use
  • Spatial consistency
  • Reduced motion

Animation performance

  • Frame rate (FPS)
  • Jank
  • GPU acceleration
  • will-change
  • Layout thrashing

Layout

  • Hero section
  • Above the fold
  • Sticky header
  • Sidebar
  • Bento grid
  • Card
  • Flexbox
  • CSS Grid
  • Padding vs margin
  • Responsive design
  • Container
  • Masonry layout
  • Split screen
  • Z-index
  • Overflow

Components

  • Button variants
  • Modal
  • Drawer
  • Popover
  • Tooltip
  • Dropdown menu
  • Context menu
  • Toast notification
  • Tabs
  • Segmented control
  • Accordion
  • Carousel
  • Command palette
  • Combobox
  • Toggle switch
  • Checkbox
  • Radio button
  • Date picker
  • Breadcrumb
  • Pagination
  • Infinite scroll
  • Badge
  • Avatar stack
  • Empty state
  • Skeleton screen
  • Spinner
  • Progress bar
  • Data table
  • Stepper
  • Floating label
  • Inline validation
  • Alert banner
  • Tag input

States & patterns

  • Interaction states
  • Focus ring
  • Loading state
  • Optimistic UI
  • Debounce
  • Lazy loading
  • Dark mode
  • Micro-interaction
  • Affordance
  • Undo
  • Drag and drop
  • Keyboard shortcut

Visual styles

  • Glassmorphism
  • Liquid glass
  • Neumorphism
  • Claymorphism
  • Neo-brutalism
  • Skeuomorphism
  • Flat design
  • Mesh gradient
  • Aurora background
  • Grain texture
  • Glow effect
  • Drop shadow
  • Border radius
  • Grid background
  • Typographic hierarchy
  • Accent color
  • Color contrast

Vibe coding & AI

  • Vibe coding
  • Prompt
  • Context window
  • Token
  • AI agent
  • Tool call
  • Hallucination
  • Diff
  • Live preview
  • Checkpoint
  • Git commit
  • Deploy
  • Frontend and backend
  • API
  • Database
  • Rules file
  • MCP
  • Plan mode
  • Visual edit
Files
  • Q3 report.pdf2.4 MB
  • Brand assets12 items
  • Team photo.jpg5.1 MB