UI Context Menu
remocn/context-menuFreeComponent
A right-click context menu whose opened/closed state is a pure function of the timeline; the panel scales from its top-left corner (the click point) with a fade + lift. No trigger — the caller positions it. Rows reuse the DropdownMenuItem row; items are plain string labels.
Install it
npx shadcn@latest add https://www.remocn.dev/r/context-menu.jsonSource
1"use client";23import {4 DropdownMenuItemRow,5 type DropdownMenuItemState,6 type DropdownMenuItemStyle,7 type DropdownMenuItemStyleContext,8 dropdownMenuItemStyle,9 dropdownMenuItemStyleContext,10} from "@/components/remocn/dropdown-menu-item";11import { type RemocnTheme, useRemocnTheme } from "@/lib/remocn-ui";1213export type ContextMenuState = "opened" | "closed";1415export interface ContextMenuProps {16 state?: ContextMenuState;17 style?: ContextMenuStyle;18 items?: string[];19 highlightedIndex?: number;20 pressedIndex?: number;21 itemStyles?: (DropdownMenuItemStyle | undefined)[];22 theme?: Partial<RemocnTheme>;23 className?: string;24}2526const WIDTH = 200;2728export interface ContextMenuStyle {29 opacity: number;30 scale: number;31 translateY: number;32}3334export interface ContextMenuStyleContext {35 panelBg: string;36 panelBorder: string;37 radius: number;38 itemCtx: DropdownMenuItemStyleContext;39}4041export function contextMenuStyleContext(42 theme: RemocnTheme,43): ContextMenuStyleContext {44 return {45 panelBg: theme.popover,46 panelBorder: theme.border,47 radius: theme.radius,48 itemCtx: dropdownMenuItemStyleContext(theme),49 };50}5152export function contextMenuStyle(53 state: ContextMenuState,54 _ctx: ContextMenuStyleContext,55): ContextMenuStyle {56 switch (state) {57 case "opened":58 return { opacity: 1, scale: 1, translateY: 0 };59 default:60 return { opacity: 0, scale: 0.95, translateY: -4 };61 }62}6364function rowState(65 i: number,66 highlightedIndex: number,67 pressedIndex: number,68): DropdownMenuItemState {69 if (i === pressedIndex) return "press";70 if (i === highlightedIndex) return "hover";71 return "idle";72}7374export function ContextMenu({75 state = "closed",76 style,77 items = ["Back", "Reload", "Save As…", "Inspect"],78 highlightedIndex = -1,79 pressedIndex = -1,80 itemStyles,81 theme: themeOverride,82 className,83}: ContextMenuProps) {84 const theme = useRemocnTheme(themeOverride, "light");85 const ctx = contextMenuStyleContext(theme);86 const v = style ?? contextMenuStyle(state, ctx);8788 return (89 <div90 className={className}91 style={{92 width: WIDTH,93 opacity: v.opacity,94 transformOrigin: "top left",95 transform: `translateY(${v.translateY}px) scale(${v.scale})`,96 background: ctx.panelBg,97 border: `1px solid ${ctx.panelBorder}`,98 borderRadius: ctx.radius + 2,99 padding: 4,100 display: "flex",101 flexDirection: "column",102 gap: 2,103// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from remocn
All 277 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| UI Accordionaccordion | remocn | Components | Free | 1 dep · 2 files | |
| UI AI Prompt Flowai-prompt-flow | remocn | Components | Free | 1 dep | |
| UI Alert Dialogalert-dialog | remocn | Components | Free | 1 dep · 2 files | |
| Animated Bar Chartanimated-bar-chart | remocn | Components | Free | 1 dep | |
| Animated Line Chartanimated-line-chart | remocn | Components | Free | 1 dep | |
| ASCII Dissolveascii-dissolve | remocn | Components | Free | 2 deps | |
| ASCII Renderascii-render | remocn | Components | Free | 1 dep | |
| Backdropbackdrop | remocn | Components | Free | 1 dep |
