Popover
An overlaid panel, triggered by a button, for showing rich content.
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 popover registry item installs these files:
-
app/components/ui_component.rb -
app/components/ui/popover_component.rb -
app/components/ui/popover/trigger_component.rb -
app/components/ui/popover/content_component.rb -
app/components/ui/button_component.rb -
app/helpers/ui/popover_helper.rb -
app/helpers/ui/button_helper.rb -
app/javascript/controllers/ui_popover_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
The ui-popover controller
toggles the panel, moves focus into it on open, and hands focus back to the trigger on
closing with Esc. Clicking outside closes it too.
Positioning is utilities only (side/align),
with no floating-ui.
Or render the components directly:
Composition
Examples
Default
A non-modal panel: it opens on click, focuses its content, and closes on an outside click or Esc.
Dimensions
Set the dimensions for the layer.
Alignment
align: :start, :center or :end shifts the panel along the cross axis.
Aligned to the start on the horizontal axis.
Aligned to the center on the horizontal axis.
Aligned to the end on the horizontal axis.
API reference
Every part accepts class /
class_name and
**attrs.
| Component | Argument | Default | Description |
|---|---|---|---|
Popover::Trigger |
variant, size |
:outline |
The Button that opens and closes it; keeps aria-expanded current. |
Popover::Content |
side |
:bottom |
:top, :right, :bottom, :left. |
Popover::Content |
align |
:center |
:start, :center, :end along the cross axis. |