Dialog
A focused task, with a sheet layout on phones.
Usage
After the one-time setup, call the helper directly from ERB. No component import is needed.
<%= lc_dialog id: "my-component-dialog", title: "Create project", description: "Projects group pages and members.", trigger: "New project" do |dialog| %>
<form method="dialog" class="flex flex-col gap-inset">
<%= lc_field label: "Project name", id: "my-component-dialog-name" do |field| %>
<%= lc_input name: "project[name]", **field %>
<% end %>
<%= dialog.footer do %>
<%= dialog.close %>
<%= lc_button "Create project", type: :submit %>
<% end %>
</form>
<% end %>
Examples
Modal
<%= lc_dialog id: "example-0-dialog", title: "Create project", description: "Projects group pages and members.", trigger: "New project" do |dialog| %>
<form method="dialog" class="flex flex-col gap-inset">
<%= lc_field label: "Project name", id: "example-0-dialog-name" do |field| %>
<%= lc_input name: "project[name]", **field %>
<% end %>
<%= dialog.footer do %>
<%= dialog.close %>
<%= lc_button "Create project", type: :submit %>
<% end %>
</form>
<% end %>
Mobile dialog
<%= lc_dialog id: "example-1-sheet", title: "Workspace details", trigger: "Open mobile dialog", detents: "fit" do %>
<p class="text-sm text-muted-foreground">On a phone this is a half sheet. Swipe it down to dismiss.</p>
<%= lc_field label: "Workspace", id: "example-1-workspace" do |field| %>
<%= lc_input value: "Design studio", **field %>
<% end %>
<% end %>
Mobile height options
<%= lc_dialog id: "example-2-sheet", title: "Notes", detents: "medium large" do %>
<%= lc_textarea name: "notes", rows: 16, aria: { label: "Notes" }, placeholder: "Write something…" %>
<% end %>
Compact dialog
<%= lc_dialog id: "example-3-context", title: "Quick details", trigger: "Open compact dialog", kind: :context do %>
<p class="text-sm text-muted-foreground">A compact dialog for a short, focused task.</p>
<% end %>
<%= lc_dialog id: "example-3-invite", title: "Invite people", kind: :context do |dialog| %>
<% dialog.trigger { |attrs| lc_button "Invite with your own trigger", variant: :ghost, **attrs } %>
<div class="flex flex-col gap-content" data-dialog-size="md">
<p class="text-sm text-muted-foreground">This step marks itself data-dialog-size="md", so the compact dialog widens to 32rem while it shows.</p>
</div>
<% end %>
Popover sheet
Filters
A popover on desktop, a sheet you can swipe away on phones.
<button type="button" class="<%= lc_button_class(variant: :secondary) %>" popovertarget="example-4-filters">Filters</button>
<%= lc_sheet id: "example-4-filters", popover: "auto", role: "dialog", aria: { labelledby: "example-4-filters-title" },
surface: :glass, class: "sm:m-auto sm:w-80 sm:rounded-3xl text-foreground" do %>
<div class="grid gap-content p-inset">
<%= lc_heading "Filters", id: "example-4-filters-title", size: :title %>
<p class="text-sm text-muted-foreground">A popover on desktop, a sheet you can swipe away on phones.</p>
<button type="button" class="<%= lc_button_class(block: true) %>" popovertarget="example-4-filters" popovertargetaction="hide">Done</button>
</div>
<% end %>
Opened by your controller
<div data-controller="lc-dialog">
<%= lc_button "Show members", variant: :secondary, aria: { haspopup: "dialog", controls: "example-5-members" }, data: { action: "lc-dialog#open" } %>
<%= lc_dialog id: "example-5-members", title: "Members", trigger: false, size: :lg, detents: "large", data: { lc_dialog_target: "dialog" } do |dialog| %>
<%= dialog.actions do %>
<%= lc_button "Invite", size: :sm %>
<% end %>
<% %w[Aiko Ben Chiara Dmitri Emi Farah Goro Hana].each do |name| %>
<p class="<%= lc_text_class %>"><%= name %></p>
<% end %>
<% end %>
</div>
Turbo confirm
<%# In the layout, once. %>
<%= lc_confirm_sheet %>
<%= lc_button_to "Delete project", "/projects/42", method: :delete, variant: :destructive, form: { data: { turbo_confirm: "Delete this project?", turbo_confirm_description: "Its pages and files are deleted for everyone.", controller: "confirm-demo", action: "confirm-demo#submit" } } %>
<%= lc_button_to "Archive", "/projects/42/archival", form: { data: { turbo_confirm: "Archive this project?", turbo_confirm_accept: "Archive project", controller: "confirm-demo", action: "confirm-demo#submit" } } %>
<%= lc_menu id: "example-6-menu", label: "Membership" do %>
<%= lc_menu_option "Leave project", href: "/projects/42/membership", method: :delete, tone: :destructive, form_attributes: { data: { turbo_confirm: "Leave this project?", turbo_confirm_accept: "Leave", controller: "confirm-demo", action: "confirm-demo#submit" } } %>
<% end %>
API reference
Helpers render semantic HTML and include their interaction wiring. Pass native attributes through class:, data:, aria: and the usual Rails options. Blocks use captured ERB content.
lc_dialog
lc_dialog(id:, title:, description: nil, trigger: lc_t("lostcoords.ui.dialog.trigger"), kind: :modal, size: nil, detents: "fit",
close_action: "lc-dialog#close", close_label: nil, title_attributes: {}, description_attributes: {}, **attributes, &block)
| Input | Default | Values |
|---|---|---|
| id | Required | — |
| title | Required | — |
| description | nil | — |
| trigger | lc_t("lostcoords.ui.dialog.trigger") | — |
| kind | :modal | :modal · :context |
| size | nil | :sm · :md · :lg · :xl |
| detents | "fit" | fit · medium large · large |
| close_action | "lc-dialog#close" | — |
| close_label | nil | — |
| title_attributes | {} | — |
| description_attributes | {} | — |
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
| block | Captured block | Captured Rails ERB content |
lc_dialog yields a builder, dialog, with these parts. Each part carries data-slot and merges class: and native attributes.
dialog.actions
dialog.actions(&block)
| Input | Default | Values |
|---|---|---|
| block | Captured block | Captured Rails ERB content |
dialog.footer
| Input | Default | Values |
|---|---|---|
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
| block | Captured block | Captured Rails ERB content |
dialog.close
dialog.close(label = nil, variant: :secondary, **attributes)
| Input | Default | Values |
|---|---|---|
| label | nil | Accessible name, visible where applicable |
| variant | :secondary | — |
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
lc_confirm_sheet
lc_confirm_sheet(**attributes)
| Input | Default | Values |
|---|---|---|
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
lc_sheet
lc_sheet(as: :div, anchored: false, detents: "fit", size: nil, surface: nil, **attributes, &block)
| Input | Default | Values |
|---|---|---|
| as | :div | — |
| anchored | false | true · false |
| detents | "fit" | fit · medium large · large |
| size | nil | — |
| surface | nil | — |
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
| block | Captured block | Captured Rails ERB content |
The examples also use lc_field, lc_input, lc_button, lc_textarea, lc_heading, lc_button_to, lc_menu, and lc_menu_option. Each is documented on its own page.
Styling and extension
Use class: to merge utilities, native attributes for application behavior, and the theming guide for the shared palette. For custom markup, the advanced class helpers expose the same styles, including glass surfaces and class merging.