Sheet
Extends Dialog to show complementary content sliding in from an edge of the screen.
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 sheet registry item installs these files:
-
app/components/ui_component.rb -
app/components/ui/sheet_component.rb -
app/components/ui/sheet/trigger_component.rb -
app/components/ui/sheet/content_component.rb -
app/components/ui/sheet/header_component.rb -
app/components/ui/sheet/footer_component.rb -
app/components/ui/sheet/title_component.rb -
app/components/ui/sheet/description_component.rb -
app/components/ui/sheet/close_component.rb -
app/components/ui/button_component.rb -
app/components/ui/icon_component.rb -
app/helpers/ui/sheet_helper.rb -
app/helpers/ui/button_helper.rb -
app/helpers/ui/icon_helper.rb -
app/javascript/controllers/ui_dialog_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 same contract as Dialog (the native
<dialog> +
controller ui-dialog),
with the panel anchored to an edge through side:.
Or render the components directly:
Composition
Examples
Default
A panel sliding in from the right, with a form and a footer.
All four sides
side: :right, :left, :top or :bottom sets the edge it comes from and the animation.
API reference
Every part accepts class /
class_name and
**attrs.
| Component | Argument | Default | Description |
|---|---|---|---|
Sheet |
close_on_backdrop |
true |
Closes on a click outside the panel. |
Sheet::Content |
side |
:right |
:right, :left, :top or :bottom. Sets data-side. |
Sheet::Content |
show_close_button |
true |
Renders the X button in the top-right corner. |
Sheet::Trigger / Sheet::Close |
variant, size |
:outline, :default |
Wrap Ui::ButtonComponent. |