Context menu preview

Interactive preview of the CyberSpec Context menu component. An area that opens a menu on right-click, a long press, or the keyboard.

About this preview

Context menu belongs to the Navigation group in the CyberSpec catalog. It uses @ui-sdk/react/menu.

Installation

Use a React 19 project with shadcn configured. Render the installed components inside the Cyber root, and import your global stylesheet in the app entry point.

bunx --bun shadcn@latest add https://www.cyberspec.dev/r/context-menu.json

Example

"use client"

import { Crosshair, Flag, Navigation, ScanLine } from "lucide-react"
import { ContextMenu } from "@/components/ui/context-menu"

export default function ContextMenuDemo() {
  return (
    <>
      <ContextMenu
        label="Grid sector 3F"
        items={[
          { value: "route", label: "Route here", icon: <Navigation aria-hidden />, shortcut: "mod+r" },
          { value: "pin", label: "Drop a pin", icon: <Flag aria-hidden /> },
          { value: "scan", label: "Scan sector", icon: <ScanLine aria-hidden />, disabled: true },
          { type: "separator" },
          { type: "checkbox", value: "patrols", label: "Show patrols", defaultChecked: true },
          { type: "checkbox", value: "cameras", label: "Show cameras" },
          { type: "separator" },
          { value: "mark", label: "Mark hostile", icon: <Crosshair aria-hidden />, destructive: true },
        ]}
      />
    </>
  )
}

Install this example

bunx --bun shadcn@latest add https://www.cyberspec.dev/r/context-menu-demo.json

Resources

View as Markdown