Componentnavigation1.75 KB gzipZero dependencies

Context Menu

Right-click menu with smooth reveal, shortcuts, and dashed divider.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add context-menu

Or install the full npm package:

npm install bigbullui

Usage

tsx11 lines
import { ContextMenu } from "@/components/ui/context-menu"; <ContextMenu  items={[    { id: "print", label: "Print Stub", shortcut: "⌘P" },    "separator",    { id: "revoke", label: "Revoke Ticket", danger: true },  ]}>  <div className="p-8 border border-dashed rounded-lg">Right-click here</div></ContextMenu>

Source code

context-menu.tsx + 3 helpers

Zero third-party dependencies (4 local files shown in tabs below).

tsxcontext-menu.tsx264 lines
"use client"; import * as React from "react";import { createPortal } from "react-dom";import { cn } from "./lib/utils";import { useIsMounted } from "./lib/react-compat";import { registerEscapeLayer } from "./lib/focus-trap"; export interface ContextMenuItem {  id: string;  label: string;  shortcut?: string;  danger?: boolean;  disabled?: boolean;  onSelect?: () => void;} export interface ContextMenuProps extends React.HTMLAttributes<HTMLDivElement> {

Props

Interactive Prop Playground

Tweak parsed AST props below to generate ready-to-paste JSX.

tsx3 lines
import { ContextMenu } from "@/components/ui/context-menu"; <ContextMenu />
PropTypeDescription
items(ContextMenuItem | "separator")[]Structured list of items rendered by the component.
childrenReact.ReactNodeChild elements rendered inside the component.
classNamestringOptional Tailwind or custom CSS classes merged with component styles.
animatedbooleanDual-mode: false renders instantly with no motion. Default true.