Class: Shadcn::ContextMenuComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/shadcn/context_menu_component.rb

Overview

Context Menu component Matches shadcn/ui ContextMenu component Displays a menu when the user right-clicks on an element

Examples:

Basic context menu

<%= render Shadcn::ContextMenuComponent.new do |menu| %>
  <% menu.with_trigger do %>
    <div class="border border-dashed p-8 text-center">
      Right click here
    </div>
  <% end %>
  <% menu.with_menu do |content| %>
    <% content.with_item(href: "#") { "Back" } %>
    <% content.with_item(href: "#", disabled: true) { "Forward" } %>
    <% content.with_item(href: "#") { "Reload" } %>
    <% content.with_separator %>
    <% content.with_item(href: "#") { "Save As..." } %>
    <% content.with_item(href: "#") { "Print" } %>
  <% end %>
<% end %>

Instance Attribute Summary

Attributes inherited from BaseComponent

#class_name, #data, #html_options

Method Summary

Methods inherited from BaseComponent

#content, #initialize

Methods included from Rails::Helpers::ClassNameHelper

#cn

Constructor Details

This class inherits a constructor from Shadcn::BaseComponent