Skip to content
Components

Dialog

A focused task, with a sheet layout on phones.

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 %>

Create project

Projects group pages and members.

<%= 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 %>

Workspace details

On a phone this is a half sheet. Swipe it down to dismiss.

<%= 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 %>

Notes

<%= 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 %>

Quick details

A compact dialog for a short, focused task.

Invite people

This step marks itself data-dialog-size="md", so the compact dialog widens to 32rem while it shows.

<%= 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 %>
<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 %>

Members

Aiko

Ben

Chiara

Dmitri

Emi

Farah

Goro

Hana

<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>

<%# 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 %>

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)
InputDefaultValues
idRequired—
titleRequired—
descriptionnil—
triggerlc_t("lostcoords.ui.dialog.trigger")—
kind:modal:modal · :context
sizenil:sm · :md · :lg · :xl
detents"fit"fit · medium large · large
close_action"lc-dialog#close"—
close_labelnil—
title_attributes{}—
description_attributes{}—
attributes{}Native HTML attributes; class:, data: and aria: merge with defaults
blockCaptured blockCaptured 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)
InputDefaultValues
blockCaptured blockCaptured Rails ERB content
InputDefaultValues
attributes{}Native HTML attributes; class:, data: and aria: merge with defaults
blockCaptured blockCaptured Rails ERB content

dialog.close

dialog.close(label = nil, variant: :secondary, **attributes)
InputDefaultValues
labelnilAccessible name, visible where applicable
variant:secondary—
attributes{}Native HTML attributes; class:, data: and aria: merge with defaults

lc_confirm_sheet

lc_confirm_sheet(**attributes)
InputDefaultValues
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)
InputDefaultValues
as:div—
anchoredfalsetrue · false
detents"fit"fit · medium large · large
sizenil—
surfacenil—
attributes{}Native HTML attributes; class:, data: and aria: merge with defaults
blockCaptured blockCaptured 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.

API JSON · LLM reference