Search

Search documentation

Context Menu

Displays a menu to the user — such as a set of actions or functions — triggered by a button.

Installation

pnpm dlx shadcn@latest add @evolphin/context-menu

Usage

import {
  ContextMenu,
  ContextMenuContent,
  ContextMenuItem,
  ContextMenuTrigger,
} from "@/components/ui/context-menu"
<ContextMenu>
  <ContextMenuTrigger>Right click</ContextMenuTrigger>
  <ContextMenuContent>
    <ContextMenuItem>Profile</ContextMenuItem>
    <ContextMenuItem>Billing</ContextMenuItem>
    <ContextMenuItem>Team</ContextMenuItem>
    <ContextMenuItem>Subscription</ContextMenuItem>
  </ContextMenuContent>
</ContextMenu>

Type Definitions

interface ContextMenuProps {
  /** Event handler called when the open state changes */
  onOpenChange?: (: boolean) => void;
ContextMenuProps.onOpenChange?: ((open: boolean) => void) | undefined

Event handler called when the open state changes

}

Examples

Default

Right click here

API Reference

ContextMenu

PropTypeDefaultDescription
onOpenChange(open: boolean) => void-Event handler called when the open state changes.
modalbooleantrueThe modality of the context menu.

ContextMenuTrigger

PropTypeDefaultDescription
disabledbooleanfalseWhether the trigger is disabled.

ContextMenuContent

PropTypeDefaultDescription
forceMountboolean-Used to force mounting when more control is needed.
alignOffsetnumber-The distance from the trigger.
classNamestring-Additional CSS classes

ContextMenuItem

PropTypeDefaultDescription
disabledbooleanfalseWhether the item is disabled.
onSelect(event: Event) => void-Event handler called when the item is selected.
insetbooleanfalseWhether to indent the item.

ContextMenuCheckboxItem

PropTypeDefaultDescription
checkedboolean | "indeterminate"-The controlled checked state of the item.
onCheckedChange(checked: boolean) => void-Event handler called when the checked state changes.

ContextMenuRadioGroup

PropTypeDefaultDescription
valuestring-The value of the selected item.
onValueChange(value: string) => void-Event handler called when the value changes.

ContextMenuRadioItem

PropTypeDefaultDescription
valuestring-The value of the item.

ContextMenuSubTrigger

PropTypeDefaultDescription
disabledbooleanfalseWhether the trigger is disabled.
insetbooleanfalseWhether to indent the item.

On this page