Componentnavigation1.75 KB gzipZero dependencies
Context Menu
Right-click menu with smooth reveal, shortcuts, and dashed divider.
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add context-menuOr install the full npm package:
npm install bigbulluiUsage
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 helpersZero 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 />| Prop | Type | Description |
|---|---|---|
| items | (ContextMenuItem | "separator")[] | Structured list of items rendered by the component. |
| children | React.ReactNode | Child elements rendered inside the component. |
| className | string | Optional Tailwind or custom CSS classes merged with component styles. |
| animated | boolean | Dual-mode: false renders instantly with no motion. Default true. |