Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Simple Context Menu for Vue

A dashed area labeled Right click here that opens Back, Forward, Reload, and More Options.

UI library: Ark UI

The dashed area reads Right click here. The menu is four plain items: Back, Forward, Reload, and More Options. No icons and no shortcut text.

Start here, then add icons or groups as the menu grows. The same four can hang off a Button in a dropdown for people who do not right-click. In Vue, Ark UI replaces the browser menu inside this area.

Preview

Preview width

Installation

MCP · Pro
Make your AI a shadcn expert
Your agent installs components, builds pages and restyles your app from one prompt, in Claude Code, Cursor or VS Code.
Part of Pro

Anatomy

Context Menu anatomy: trigger, item, sub trigger, separator, item indicator, content

Usage

<ContextMenu>
  <ContextMenuTrigger class="flex h-[200px] w-full max-w-lg items-center justify-center rounded-md border border-dashed text-sm">
    <span class="pointer-fine:inline-block hidden">Right click here</span>
    <span class="pointer-coarse:inline-block hidden">Long press here</span>
  </ContextMenuTrigger>
  <ContextMenuContent class="w-56">
    <ContextMenuGroup>
      <ContextMenuItem value="back">Back</ContextMenuItem>
      <ContextMenuItem value="forward">Forward</ContextMenuItem>
      <ContextMenuItem value="reload">Reload</ContextMenuItem>
      <ContextMenuItem value="more-options">More Options</ContextMenuItem>
    </ContextMenuGroup>
  </ContextMenuContent>
</ContextMenu>

FAQ

What opens the menu?

A right-click inside the dashed area, which reads Right click here on a mouse and Long press here on a touch screen. The area is ContextMenuTrigger; a long press on it opens the menu too. Wrap your own row, file or canvas in the trigger instead.

Which parts make up the menu?

ContextMenu, the trigger, the popup and four ContextMenuItems in one ContextMenuGroup. Nothing else is needed for a flat list.

How do I run an action when an item is chosen?

Each item has a value; listen to @select on ContextMenu, which receives { value }.

The menu closes after the action runs.

Does it replace the browser's menu?

Inside the trigger, yes: a right-click there opens this menu instead of the browser's. Keep the trigger to the area that needs custom actions.

How do keyboard and touch users find these actions?

The arrow keys move through an open menu, Enter runs an item and Escape closes it. A right-click is easy to miss, so also offer the same actions from a visible button, such as a Dropdown Menu.

How wide is the menu?

w-56 on the popup. Set your own width class for longer labels.

API Reference

Context Menu

Sets value="back", value="forward", value="reload" and value="more-options". The rest is on the Context Menu page.