ReScript Shadcn
Get started
  • Installation
Components
  • Accordion
  • Alert
  • AlertDialog
  • AspectRatio
  • Attachment
  • Avatar
  • Badge
  • Breadcrumb
  • Bubble
  • Button
  • ButtonGroup
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Collapsible
  • Combobox
  • Command
  • ContextMenu
  • DataTable
  • DatePicker
  • Dialog
  • Direction
  • Drawer
  • DropdownMenu
  • Empty
  • Field
  • HoverCard
  • Input
  • InputGroup
  • InputOtp
  • Item
  • Kbd
  • Label
  • Marker
  • Menubar
  • Message
  • MessageScroller
  • NativeSelect
  • NavigationMenu
  • Pagination
  • Popover
  • Progress
  • RadioGroup
  • Resizable
  • ScrollArea
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Skeleton
  • Slider
  • Sonner
  • Spinner
  • Switch
  • Table
  • Tabs
  • Textarea
  • Toast
  • Toggle
  • ToggleGroup
  • Tooltip
  • Typography

Context Menu

Displays a menu of actions triggered by a right click.

Right click hereLong press here

Installation#

npx shadcn@latest add @rescript-shadcn/ContextMenu

Usage#

<ContextMenu>
  <ContextMenu.Trigger> {"Right click here"->React.string} </ContextMenu.Trigger>
  <ContextMenu.Content>
    <ContextMenu.Item> {"Profile"->React.string} </ContextMenu.Item>
    <ContextMenu.Item> {"Billing"->React.string} </ContextMenu.Item>
    <ContextMenu.Item> {"Team"->React.string} </ContextMenu.Item>
    <ContextMenu.Item> {"Subscription"->React.string} </ContextMenu.Item>
  </ContextMenu.Content>
</ContextMenu>

Examples#

Basic#

A simple context menu with a few actions.

Right click hereLong press here

Submenu#

Use ContextMenuSub to nest secondary actions.

Right click hereLong press here

Shortcuts#

Add ContextMenuShortcut to show keyboard hints.

Right click hereLong press here

Groups#

Group related actions and separate them with dividers.

Right click hereLong press here

Icons#

Combine icons with labels for quick scanning.

Right click hereLong press here

Checkboxes#

Use ContextMenuCheckboxItem for toggles.

Right click hereLong press here

Radio#

Use ContextMenuRadioItem for exclusive choices.

Right click hereLong press here

Destructive#

Use variant=Destructive to style the menu item as destructive.

Right click hereLong press here

Sides#

Control submenu placement with side and align props.

Right click (top)Long press (top)
Right click (right)Long press (right)
Right click (bottom)Long press (bottom)
Right click (left)Long press (left)

API Reference#

See the Base UI documentation for more information.

@@directive("'use client'")

@react.component
@react.component
let make = () =>
  <ContextMenu>
@react.component
let make = () =>
  <ContextMenu>
@react.component
let make = () =>
  <ContextMenu>
@react.component
let make = () =>
  <ContextMenu>
@react.component
let make = () =>
  <ContextMenu>
@react.component
let make = () =>
  <ContextMenu>
@react.component
let make = () =>
  <ContextMenu>
@react.component
let make = () =>
  <div className="grid w-full max-w-sm grid-cols-2 gap-4">
@react.component
let make = () =>
  <ContextMenu>