Skip to content
IndexRequest a UIAboutContact

Long Press Menu

Press and hold a tile to open a context menu, with visible progress while holding.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Create a 120x120px tile labelled "Photo 01". Use pointer events: on pointerdown start a 500ms timer and animate a circular progress ring around the pointer-down area (an SVG circle with stroke-dashoffset animating over 500ms linear). If the pointer is released earlier or moves more than 10px, cancel and reset the ring. When the timer completes, open a menu with the actions Share, Rename and Delete positioned next to the tile; the menu fades and scales from 0.96 in 140ms. Prevent the native context menu with the contextmenu event, and also open the menu when the ContextMenu key or Shift+F10 is pressed while the tile is focused. Menu items are buttons; arrow keys move between them, Escape closes and returns focus to the tile. Selecting an item shows "Share chosen" etc. in an aria-live line. Clicking outside closes the menu. Under prefers-reduced-motion remove the ring and animation.

About this pattern

Definition

A hold gesture: pressing an element for about half a second opens a menu of actions for it. A growing ring shows the hold progress so the gesture feels deliberate.

Purpose & UX principles

  • Reveals secondary actions without cluttering the interface.
  • Visible progress teaches the gesture and lets people cancel by releasing early.
  • Keyboard equivalent: the Menu key or Shift+F10 opens the same menu.

Interaction states

  • Idle, holding (ring grows), open (menu shown, tile highlighted), cancelled, focus-visible.

Motion specification

  • The ring fills over 500ms linear, matching the hold time.
  • The menu fades and scales from 0.96 in 140ms.
  • Reduced motion: no ring animation; the menu appears instantly.

Responsive behaviour

  • Works with touch and mouse; the hold time is 500ms and a movement over 10px cancels it.
  • The menu opens within the viewport, flipping above when near the bottom.

Code

HTML
<div class="wrap">
  <button class="tile" id="tile" aria-haspopup="menu">Photo 01<svg class="ring" viewBox="0 0 40 40" aria-hidden="true"><circle cx="20" cy="20" r="17"/></svg></button>
  <div class="menu" id="menu" role="menu" hidden>
    <button role="menuitem">Share</button><button role="menuitem">Rename</button><button role="menuitem">Delete</button>
  </div>
  <p class="live" id="live" aria-live="polite">Press and hold the tile.</p>
</div>

Related patterns

Drag to Reorder

↗
Drag to ReorderGestures & Touch

Dropdown Menu

↗
Dropdown MenuOverlays & Dialogs

Press Feedback

↗
Press FeedbackButtons & Actions