Sheet

Examples

Default

Extends the Dialog component to display content that complements the main content of the screen.

<%= render "ui/sheet" do %>
  <%= render "ui/sheet/trigger", as_child: true do |attrs| %>
    <%= render "ui/button", variant: :outline, attributes: attrs do %>Open<% end %>
  <% end %>
  <%= render "ui/sheet/overlay" do %>
    <%= render "ui/sheet/content" do %>
      <%= render "ui/sheet/header" do %>
        <%= render "ui/sheet/title" do %>Edit profile<% end %>
        <%= render "ui/sheet/description" do %>Make changes to your profile here.<% end %>
      <% end %>
      <div class="p-4">Content goes here.</div>
      <%= render "ui/sheet/footer" do %>
        <%= render "ui/sheet/close" do %>Close<% end %>
      <% end %>
    <% end %>
  <% end %>
<% end %>

Side

Use the side property to position the sheet.

<div class="flex gap-2">
  <% %w[top right bottom left].each do |side| %>
    <%= render "ui/sheet" do %>
      <%= render "ui/sheet/trigger", as_child: true do |attrs| %>
        <%= render "ui/button", variant: :outline, attributes: attrs do %><%= side.capitalize %><% end %>
      <% end %>
      <%= render "ui/sheet/overlay" do %>
        <%= render "ui/sheet/content", side: side do %>
          <%= render "ui/sheet/header" do %>
            <%= render "ui/sheet/title" do %><%= side.capitalize %> Sheet<% end %>
          <% end %>
          <div class="p-4">Content</div>
        <% end %>
      <% end %>
    <% end %>
  <% end %>
</div>

Features

  • Custom styling with Tailwind classes

API Reference

Sheet

Parameters

NameTypeDefaultDescription
openBooleanfalseWhether the element is open
close_on_escapeBooleantrueThe close on escape
close_on_overlay_clickBooleantrueThe close on overlay click

Close

Parameters

NameTypeDefaultDescription
as_childBooleanfalseWhen true, yields attributes to block instead of rendering wrapper
variantSymbol:outlineVisual style variant
sizeSymbol:defaultSize of the element

Content

Parameters

NameTypeDefaultDescription
sideStringrightWhich side to display on
openBooleanfalseWhether the element is open
show_closeBooleantrueThe show close

Description

Footer

Header

Overlay

Parameters

NameTypeDefaultDescription
openBooleanfalseWhether the element is open

Title

Trigger

Parameters

NameTypeDefaultDescription
as_childBooleanfalseWhen true, yields attributes to block instead of rendering wrapper

Accessibility

Implements the WAI-ARIA Dialog (Modal) pattern with proper roles, states, and keyboard navigation.