Skip to content
Sign upPro
ShellLong press menuMenu

Long press menu (Pro)

ProIncluded in $99

Press and hold a message for its actions: it sinks, pops, lifts above a blurred screen, and the menu opens beside it.

ProPress and hold any message, or right click it, for its actions.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/long-press-menu

Needs chatcn Pro

This command works with a Pro license, along with every Pro component.

Or start free: sign up and get three Pro components on us, with a new one every month.

Usage

tsx
import { LongPressMenu } from "@/components/ui/chatcn/pro/long-press-menu"

<div data-long-press-root className="relative h-dvh">   {/* the screen the menu covers */}
  <LongPressMenu
    label="Message actions"
    align="end"
    actions={[
      { id: "copy", label: "Copy", icon: <CopyIcon />, onAction: copy },
      { id: "edit", label: "Edit", icon: <PencilIcon />, onAction: edit },
      { id: "delete", label: "Delete", icon: <TrashIcon />, destructive: true, onAction: remove },
    ]}
  >
    <MessageBubble />
  </LongPressMenu>
</div>

Hold for 450 ms (delay): the message sinks slightly while held, then pops with a short vibration where the device has one. The screen behind blurs and the message lifts out above a menu; if it is near the bottom it moves up so the menu fits, and a tall message gets the menu above it. Moving more than 8 px cancels the hold, so scrolling a long chat never opens it, and the release after a hold is not counted as a tap. Right click, the context menu key, Shift F10 or Enter on the focused message open the same menu. Destructive actions sit last, in red, after a line. The overlay covers the nearest [data-long-press-root], measured in its own pixels, so it lines up inside a scaled phone frame.

Examples

States

ProA message near the bottom of the screen lifts so the menu fits.

Props

PropTypeNotes
actionsLongPressAction[]{ id, label, icon?, destructive?, disabled?, onAction }
delaynumberHold time in ms. Default 450
labelstringThe menu's name
align"start" | "end"Which edge the menu lines up with
disabledbooleanNo menu

Keyboard

KeyAction
Enter, Space, context menu key, Shift F10Open the menu
Arrow up, down, Home, EndMove through the actions, skipping disabled ones
EnterRun the action
Escape, TabClose; focus returns to the message

Accessibility

  • The message is a button that reports it opens a menu and whether it is open.
  • The menu is a labelled menu of menu items; the lifted copy of the message is hidden from screen readers.
  • Disabled actions say so and are skipped by the arrow keys.

Motion

The message sinks to 97% over the hold, lifts on a critically damped spring over 420 ms, and the menu fades and sharpens in over 260 ms. Closing reverses it in 240 ms. Under reduced motion it opens and closes in place.