Context Menu
tripled/context-menu-shadcnuiFreeComponent
Right-click context menu with nested items animation
Live preview
live · rendered by the registry
Rendered by tripled on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ui.tripled.work/r/context-menu-shadcnui.jsonSource
1"use client";23import { AnimatePresence, motion } from "framer-motion";4import { Copy, Edit, Share, Trash } from "lucide-react";5import { useState } from "react";67const menuItems = [8 { icon: Copy, label: "Copy", shortcut: "⌘C" },9 { icon: Edit, label: "Edit", shortcut: "⌘E" },10 { icon: Share, label: "Share", shortcut: "⌘S" },11 { icon: Trash, label: "Delete", shortcut: "⌘D", danger: true },12];1314export function ContextMenu() {15 const [position, setPosition] = useState({ x: 0, y: 0 });16 const [isVisible, setIsVisible] = useState(false);1718 const handleContextMenu = (e: React.MouseEvent) => {19 e.preventDefault();20 setPosition({ x: e.clientX, y: e.clientY });21 setIsVisible(true);22 };2324 return (25 <>26 <div27 onContextMenu={handleContextMenu}28 onClick={() => setIsVisible(false)}29 className="flex h-64 w-64 items-center justify-center rounded-2xl border-2 border-dashed bg-[var(--card-bg)]"30 >31 <p className="text-sm text-[var(--foreground)]/60">Right-click here</p>32 </div>3334 <AnimatePresence>35 {isVisible && (36 <>37 <div38 className="fixed inset-0 z-40"39 onClick={() => setIsVisible(false)}40 />41 <motion.div42 initial={{ opacity: 0, scale: 0.95 }}43 animate={{ opacity: 1, scale: 1 }}44 exit={{ opacity: 0, scale: 0.95 }}45 transition={{ duration: 0.15 }}46 className="fixed bg-card z-50 w-56 rounded-xl border bg-[var(--card-bg)] p-2 shadow-2xl"47 style={{ left: position.x, top: position.y }}48 >49 {menuItems.map((item, index) => {50 const Icon = item.icon;51 return (52 <motion.button53 key={item.label}54 initial={{ opacity: 0, x: -10 }}55 animate={{ opacity: 1, x: 0 }}56 transition={{ delay: index * 0.05 }}57 className={`flex w-full items-center justify-between rounded-lg px-3 py-2 text-left text-sm ${58 item.danger59 ? "text-red-500 hover:bg-red-500/10"60 : "hover:bg-accent/10"61 }`}62 whileHover={{ x: 4 }}63 onClick={() => setIsVisible(false)}64 >65 <div className="flex items-center gap-3">66 <Icon className="h-4 w-4" />67// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from tripled
All 282 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| AI Chat Interfaceai-chat-interface-shadcnui | tripled | Components | Free | 2 deps | |
| AI Glow Inputai-glow-input-shadcnui | tripled | Components | Free | 2 deps | |
| AI Loading Skeletonai-loading-skeleton-shadcnui | tripled | Components | Free | 2 deps | |
| AI Response Typing Streamai-response-typing-shadcnui | tripled | Components | Free | 2 deps | |
| AI Unlock Animationai-unlock-animation-shadcnui | tripled | Components | Free | 2 deps | |
| Animated Accordionanimated-accordion-shadcnui | tripled | Components | Free | 2 deps | |
| Animated Card Stackanimated-card-stack-baseui | tripled | Components | Free | 2 deps | |
| Animated Card Stackanimated-card-stack-shadcnui | tripled | Components | Free | 2 deps |
