Context Menu

Instantly reveals a contextual menu at the precise location of your right-click, allowing users to quickly interact with actions that are relevant to the current element or interface state.

Example

Right click anywhere in this box
Usage

Installation

Install following dependencies:

npm install react-aria-components tw-animate-css tailwindcss-react-aria-components class-variance-authority lucide-react clsx tailwind-merge motion

Add cn helper using clsx and twMerge for conditional class merging in Tailwind components.

lib/utils.ts

Copy and paste the following code into your project.

components/ui/core/context-menu.tsx
npx libravelui@latest add context-menu

Anatomy

import {
  ContextMenu,
  ContextMenuContent,
  ContextMenuTrigger,
  ContextMenuItem,
  ContextMenuLabel,
  ContextMenuDescription,
  ContextMenuSeparator,
  ContextMenuGroup,
  ContextMenuShortcut,
  ContextMenuSub,
  ContextMenuSubTrigger,
  ContextMenuSubContent,
} from "@/components/ui/core/context-menu";
<ContextMenu>
  <ContextMenuTrigger className="h-36 w-72 border-2 border-dashed rounded-xl flex items-center justify-center text-sm text-muted-foreground">
    Right click anywhere in this box
  </ContextMenuTrigger>

  <ContextMenuContent>
    <ContextMenuItem>ITEM GOES HERE</ContextMenuItem>
    <ContextMenuItem>ITEM GOES HERE</ContextMenuItem>
    <ContextMenuSeparator />
    <ContextMenuItem>ITEM GOES HERE</ContextMenuItem>
  </ContextMenuContent>
</ContextMenu>

Another Example

With Card

A context menu where the trigger element is implemented using a Card component, allowing the menu to be activated by interacting with the card UI.

“Hey, are we still on for tomorrow’s meeting at 10 AM?”
10:21 AM
Usage

Props

Loading types…

Accessible React component library to copy, customize, and own your UI. Built for Next.js, Vite, and Laravel.

Crafted by dervyon. Peep the Source Code on GitHub.

Hosted on Vercel. The source code's got the MIT license.

2025 - 2026 · LibravelUI

Starter Kits

Templates

    Coming Soon

Labs