Drawer

Drawer component for sliding panel overlays.

Drawer Title

Drawer content goes here.

Usage

# <% Async drawer (loads content via Turbo Frame) %>
<%= ui.btn "Open Drawer", url: some_path, data: { turbo_frame: :drawer } %>

# <% Sync drawer (content already on page) %>
<%= ui.btn "Open Drawer", data: { drawers_target: "trigger", action: "click->drawers#show", id: "myDrawer" } %>
<%= ui.drawer(title: "Title", id: "myDrawer") do %>
  <%= ui.drawer_body do %>
    Content here
  <% end %>
<% end %>
Props
PropTypeDefaultDescription
titleStringnilDrawer title displayed in the header.
subtitleStringnilDrawer subtitle displayed below the title.
sizeString
"sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl"
"2xl"Maximum width of the drawer panel.
idStringnilUnique identifier for sync drawers. Required for drawers triggered by `drawers#show` action.

Also accepts any HTML attributes via **options (e.g., id:, data:, aria:). class: is also supported for custom styling.

SubcomponentsUse subcomponents below or any HTML.
NameHelperDescription
drawer_headerui.drawer_headerHeader section with title, subtitle, and close button. Automatically rendered when title/subtitle props are provided.
drawer_bodyui.drawer_bodyScrollable content area of the drawer.
drawer_footerui.drawer_footerFooter section typically containing action buttons.

Examples

Async Drawer

<%= ui.btn "Async Drawer", url: terms_path, data: { turbo_frame: :drawer } %>

Sync Drawer

Info

Drawer content goes here.

<%= ui.btn "Sync Drawer", data: { drawers_target: "trigger", action: "click->drawers#show", id: "drawer1" } %>
<%= ui.drawer(title: "Info", id: "drawer1") do %>
  <%= ui.drawer_body do %>
    <p class="mb-6">Drawer content goes here.</p>
  <% end %>
  <%= ui.drawer_footer do %>
    <%= ui.btn "Learn more", href: "#" %>
    <%= ui.btn "Get access", href: "#" %>
  <% end %>
<% end %>

With Body and Footer

Info

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

<%= ui.btn "Open Drawer", data: { drawers_target: "trigger", action: "click->drawers#show", id: "drawer1" } %>
<%= ui.drawer(title: "Info", id: "drawer1") do %>
  <%= ui.drawer_body do %>
    <% 3.times do %>
      <p class="mb-6">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
    <% end %>
  <% end %>
  <%= ui.drawer_footer do %>
    <%= ui.btn "Learn more", href: "#" %>
    <%= ui.btn "Get access", href: "#" %>
  <% end %>
<% end %>