<div class="flex items-center justify-center w-full h-full absolute"> <div data-controller="popover" data-popover-open-value="false" data-popover-rotate-toggle-value="false" class="lui-popover"> <button popovertarget="popover-a2f8c39196d7e1ebc1a3-target" data-controller="popover-toggle" data-popover-target="toggle" data-popover-toggle-position-value="bottom_left" data-popover-toggle-anchor-value="top_left" data-popover-toggle-on-close-value="" data-popover-toggle-rotate-value="false" type="button" class="lui-popover-toggle-wrapper"> <span class="text-primary-sm-bold cursor-pointer">Open</span> </button> <div id="popover-a2f8c39196d7e1ebc1a3-target" popover="auto" data-popover-target="popover" class="pointer-events-none w-full h-full bg-transparent overflow-hidden"> <div class="bg-white lui-popover-inner absolute pointer-events-auto"> <div class="w-full w-full lui-dummy_slot text-[#78818a] text-primary-xs-bold leading-none"> Custom toggle content </div> </div> </div> </div></div><div class="flex items-center justify-center w-full h-full absolute"> <%= render LooposUi::Popover.new do |popover| %> <% popover.with_custom_toggle do %> <span class="text-primary-sm-bold cursor-pointer">Open</span> <% end %> <% popover.with_target do %> <%= render LooposUi::DummySlot.new do %> Custom toggle content <% end %> <% end %> <% end %></div>No notes provided.
No params configured.
Description
The Popover component is a container that can be toggled to show or hide its content. It is commonly used in conjunction with the ModelAssociationOverlay component. The content will be hidden by default, and when the user clicks on the button, the content will be shown.
Arguments
| Property | Default | Description |
|---|---|---|
id |
Generated | Probably wont need to set it manually |
position |
:bottom_left |
The position where the popover will be shown, relative to the toggle button. |
mode |
:auto |
The mode of the popover. Can be :auto or :manual. If :auto, the popover will be shown on click. More notes bellow. |
anchor |
:top_left |
The anchor for the target that will be attached to position. |
anchor_selector |
nil |
The anchor element where the popover will be positioned. Defaults to the toggle slot |
on_close |
nil |
Can be nil or :refresh. If :refresh, will refresh the page on close (with turbo target lui-main-layout). |
open |
false |
Default state |
rotate_toggle |
false |
Animates the toggle by rotating it by 180º when opening/closing the popover |
Position values:
:top_left:top_center:top_right:bottom_left(default):bottom_center:bottom_right
Anchor values:
:top_left(default):top_right:bottom_left:bottom_right
Manual mode
When in manual mode, you're responsible for showing and hiding the popover.
You can do so calling toggle, show and hide methods on the component instance.
Eg:
Slots
toggle - Slot for the toggle button. It is a required slot. It's a typed slot, you have two options:
with_toggle_button: Easy way, uses theButtoncomponent to create the toggle button.with_custom_toggle: Hard way. If you use this, somewhere in your custom toggle must bebuttontag with the attributes provided by thePopover's componenttoggle_attributesinstance method. If you want to use a LooposUI button, usebutton_attributesinstead. Example:<%= render LooposUi::Popover.new do |popover| ><% popover.with_custom_toggle do ><%= tag.button(..., **popover.toggle_attributes) %><%# OR %><%= tag.input(..., **popover.toggle_attributes) %><%# OR %><%= render LooposUi::Button.new(..., **popover.button_attributes) %><% end %><% end %>
target - Any content you want to show when the Popover is open. It is a required slot.