Components

Context Menu

The shadcn/ui Context Menu with menus that grow out of the cursor and smooth highlights — plus an animated React right-click menu block built with Motion and Radix that opens from the click point, staggers its items and glides a highlight between them.

  • Drop-in shadcn API
  • Right-click & long-press
  • Sub-menus
  • Checkbox & radio items
  • Motion block
aurora-hero.pngRight-click anywhere in this box

Installation

$ npx shadcn@latest add https://duskui.com/r/context-menu.json

Same exports and props as the shadcn/ui Context Menu (including inset and variant="destructive"), so it drops into existing code. Animations are CSS (tw-animate-css), so the base needs no Motion.

Usage

file-menu.tsx
import {
  ContextMenu,
  ContextMenuContent,
  ContextMenuItem,
  ContextMenuSeparator,
  ContextMenuShortcut,
  ContextMenuTrigger,
} from "@/components/ui/context-menu"

export function FileMenu() {
  return (
    <ContextMenu>
      <ContextMenuTrigger className="rounded-lg border p-8">Right-click me</ContextMenuTrigger>
      <ContextMenuContent className="w-52">
        <ContextMenuItem>
          Copy
          <ContextMenuShortcut>⌘C</ContextMenuShortcut>
        </ContextMenuItem>
        <ContextMenuItem>Rename</ContextMenuItem>
        <ContextMenuSeparator />
        <ContextMenuItem variant="destructive">Delete</ContextMenuItem>
      </ContextMenuContent>
    </ContextMenu>
  )
}

Examples

Default

Right-click (or long-press on touch) the area. The menu scales out of the exact point you clicked (Radix's transform origin) and closes faster than it opened. Includes shortcuts, a disabled item, a sub-menu, checkbox and radio items whose indicators fade in, and a destructive item.

Right-click here (or long-press)

Blocks

Ready-made variations composed from the base component with Motion. Each installs on its own and pulls in its dependencies automatically.

Animated Context Menu

Opens from the cursor point while items fade in one after another. A highlight pill glides between items as you hover or arrow through them (a shared Motion layoutId per menu level), check marks draw themselves, radio dots scale in, separators draw across and sub-menus slide out the same way. Call event.preventDefault() in onSelect to keep the menu open while toggling.

aurora-hero.pngRight-click anywhere in this box
$ npx shadcn@latest add https://duskui.com/r/animated-context-menu.json
PropTypeDefaultDescription
AnimatedContextMenuRadix Root props—onOpenChange, modal, dir.
AnimatedContextMenuTriggerRadix Trigger props—The right-click area. disabled turns the menu off.
AnimatedContextMenuContentRadix Content props & { stagger?: number }—stagger is the delay between items in seconds (default 0.03).
AnimatedContextMenuItemRadix Item props & { icon?, shortcut?, variant? }—An action. variant="destructive" tints it red.
AnimatedContextMenuCheckboxItemRadix CheckboxItem props & { checked?, shortcut? }—A toggle with a self-drawing check mark.
AnimatedContextMenuRadioGroup / RadioItemRadix props—Single choice with a dot that scales in.
AnimatedContextMenuSub / SubTrigger / SubContentRadix props & { icon? } / { stagger? }—A nested menu with its own gliding highlight.
AnimatedContextMenuLabel / Separator / GroupRadix props—Headings, dividers and groups that animate with the items.

API Reference

Same parts as shadcn/ui: ContextMenu, Trigger, Content, Item, CheckboxItem, RadioGroup, RadioItem, Label, Separator, Shortcut, Group, Portal, Sub, SubTrigger and SubContent (all prefixed ContextMenu). Each forwards the Radix props.

PropTypeDefaultDescription
onOpenChange / modal(open: boolean) => void / boolean— / trueOn ContextMenu. Radix Context Menu is uncontrolled.
disabledboolean—Turn the menu off for this area (on ContextMenuTrigger).
onSelect(event: Event) => void—Fires on click, Enter or Space; preventDefault() keeps the menu open (on items).
variant"default" | "destructive""default"Red destructive item (on ContextMenuItem).
insetboolean—Indent to align with items that have an indicator (Item, Label, SubTrigger).
checked / onCheckedChangeboolean / (checked: boolean) => void—On ContextMenuCheckboxItem.
value / onValueChangestring / (value: string) => void—On ContextMenuRadioGroup.

Accessibility

  • Built on Radix Context Menu: role="menu" with menuitem, menuitemcheckbox and menuitemradio roles, roving focus and typeahead.
  • Opens with right-click, long-press on touch, or the context-menu key / Shift+F10 — give the trigger tabIndex={0} (as the demos do) so keyboard users can focus it.
  • Arrow keys move between items, Right/Left open and close sub-menus, Enter/Space select and Escape closes.
  • In the Animated Context Menu the highlight follows keyboard focus as well as the pointer, and an open sub-menu keeps its trigger highlighted.
  • Under prefers-reduced-motion menus only fade, the cascade is removed and the highlight jumps instead of gliding.