Context Menu
A menu opened with the right mouse button, positioned at the pointer, with keyboard navigation.
Installation
Shadwire follows shadcn/ui's open code model: the component's source is copied into your application and becomes yours. Install it with the CLI:
The context-menu registry item installs these files:
-
app/components/ui_component.rb -
app/components/ui/context_menu_component.rb -
app/components/ui/context_menu/trigger_component.rb -
app/components/ui/context_menu/content_component.rb -
app/components/ui/context_menu/item_component.rb -
app/components/ui/context_menu/label_component.rb -
app/components/ui/context_menu/separator_component.rb -
app/components/ui/context_menu/group_component.rb -
app/components/ui/context_menu/shortcut_component.rb -
app/helpers/ui/context_menu_helper.rb -
app/javascript/controllers/ui_context_menu_controller.js -
vendor/shadwire/shadwire.css
This component uses Stimulus, so the application needs importmap-rails and stimulus-rails with automatic controller loading.
Haven't installed the CLI yet? gem install shadwire, then shadwire init.
Usage
Examples
API reference
Every part accepts class / class_name and **attrs.
| Component | Argument | Default | Description |
|---|---|---|---|
ContextMenu::Item |
inset |
false |
Indents it to line up with the items that have an icon. |
ContextMenu::Item |
variant |
:default |
:destructive marks a dangerous action. |
ContextMenu::Item |
disabled |
false |
Disables it: not clickable, and skipped by the keyboard. |
ContextMenu::Item |
tag |
:button |
:a with href: for an item that navigates. |
ContextMenu::Label |
inset |
false |
Indents it to line up with the items that have an icon. |