Context Menu
Displays a menu to the user — such as a set of actions or functions — triggered by a right click.
Usage
Example
Right click here
ContextMenu do ContextMenuTrigger(class: 'flex h-[150px] w-[300px] items-center justify-center rounded-md border border-dashed text-sm') { "Right click here" } ContextMenuContent(class: 'w-64') do ContextMenuItem(href: '#', shortcut: "⌘[") { "Back" } ContextMenuItem(href: '#', shortcut: "⌘]", disabled: true) { "Forward" } ContextMenuItem(href: '#', shortcut: "⌘R") { "Reload" } ContextMenuSeparator ContextMenuItem(href: '#', shortcut: "⌘⇧B", checked: true) { "Show Bookmarks Bar" } ContextMenuItem(href: '#') { "Show Full URLs" } ContextMenuSeparator ContextMenuLabel(inset: true) { "More Tools" } ContextMenuSeparator ContextMenuItem(href: '#') { "Developer Tools" } ContextMenuItem(href: '#') { "Task Manager" } ContextMenuItem(href: '#') { "Extensions" } end end
Copied!
Copy failed!
Placement
Right click hereright
Right click hereleft
div(class: 'space-y-4') do ContextMenu(options: { placement: 'right' }) do ContextMenuTrigger(class: 'flex flex-col items-center gap-y-2 h-[150px] w-[300px] items-center justify-center rounded-md border border-dashed text-sm') do plain "Right click here" Badge(variant: :primary) { "right" } end ContextMenuContent(class: 'w-64') do ContextMenuItem(href: '#', shortcut: "⌘[") { "Back" } ContextMenuItem(href: '#', shortcut: "⌘]", disabled: true) { "Forward" } ContextMenuItem(href: '#', shortcut: "⌘R") { "Reload" } ContextMenuSeparator ContextMenuItem(href: '#', shortcut: "⌘⇧B", checked: true) { "Show Bookmarks Bar" } ContextMenuItem(href: '#') { "Show Full URLs" } ContextMenuSeparator ContextMenuLabel(inset: true) { "More Tools" } ContextMenuSeparator ContextMenuItem(href: '#') { "Developer Tools" } ContextMenuItem(href: '#') { "Task Manager" } ContextMenuItem(href: '#') { "Extensions" } end end ContextMenu(options: { placement: 'left' }) do ContextMenuTrigger(class: 'flex flex-col items-center gap-y-2 h-[150px] w-[300px] items-center justify-center rounded-md border border-dashed text-sm') do plain "Right click here" Badge(variant: :primary) { "left" } end ContextMenuContent(class: 'w-64') do ContextMenuItem(href: '#', shortcut: "⌘[") { "Back" } ContextMenuItem(href: '#', shortcut: "⌘]", disabled: true) { "Forward" } ContextMenuItem(href: '#', shortcut: "⌘R") { "Reload" } ContextMenuSeparator ContextMenuItem(href: '#', shortcut: "⌘⇧B", checked: true) { "Show Bookmarks Bar" } ContextMenuItem(href: '#') { "Show Full URLs" } ContextMenuSeparator ContextMenuLabel(inset: true) { "More Tools" } ContextMenuSeparator ContextMenuItem(href: '#') { "Developer Tools" } ContextMenuItem(href: '#') { "Task Manager" } ContextMenuItem(href: '#') { "Extensions" } end end end
Copied!
Copy failed!
Components
Component | Built using | Source |
---|---|---|
ContextMenu | Phlex | |
ContextMenuContent | Phlex | |
ContextMenuItem | Phlex | |
ContextMenuLabel | Phlex | |
ContextMenuSeparator | Phlex | |
ContextMenuTrigger | Phlex | |
PopoverController | Stimulus JS |