Collapsible Edit

An interactive component which expands/collapses a panel.

Examples

@peduarte starred 3 repositories

@radix-ui/primitives

Installation


  rails generate shadcn-ui collapsible

Usage

<%= render_collapsible trigger: do %>
  <% collapsible_preview do %>
  <% end %>

  <% collapsible_body do %>
  <% end %>
<% end %>

The Collapsible component introduces:

  • app/helpers/components/collapsible_helper.rb
  • app/views/components/ui/_collapsible.html.erb
  • app/javascript/controllers/ui/collapsible_controller.js

Collapsible introduces the render_collapsible method that accepts an argument trigger: which is the text you want to show that will trigger the collapsible menu and a block. Within the block of collapsible, you can call collapsible_preview to define an element that is visible from the collapsible menu via a block. Similarly, you can call collapsible_body and pass it a block for the elements that are hidden that will be made visible when the trigger is pressed.