The personal finance app for everyone (by everyone)
Ruby
<%= wrapper_element do %>
<%# `role="dialog"` + `aria-modal="true"` is redundant with `<dialog>`
in modern browsers, but Safari and screen readers older than the
2024 WAI-ARIA Mapping still benefit from the explicit role.
`aria-labelledby` is always emitted with the stable `title_id`. When
the header slot rendered an auto-title (the common case), AT
resolves the reference and announces the title. When no title is
rendered (`custom_header: true`, body-only dialogs), the dangling
reference is silently ignored per the WAI-ARIA spec, and callers
can supply `aria-label` / `aria-labelledby` via `**opts` (last-wins)
for an explicit accessible name. The conditional `if has_auto_title?`
gate was a no-op here: the `renders_one :header` slot lambda is
evaluated lazily at slot-render time (after the `<dialog>` opening
tag attributes are computed), so the flag was never `true` when
this attribute was read. %>
<%= tag.dialog class: "w-full h-full bg-transparent text-primary backdrop:bg-overlay pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)] #{(drawer? || responsive?) ? "lg:p-3" : "lg:p-1"}",
role: "dialog",
"aria-modal": "true",
"aria-labelledby": title_id,
**merged_opts do %>
<%= tag.div class: dialog_outer_classes do %>
<%= tag.div class: dialog_inner_classes, data: { DS__dialog_target: "content" } do %>
<div class="grow py-4 space-y-4 flex flex-col <%= "overflow-auto" if scrollable %>">
<% if header? %>
<%= header %>
<% end %>
<% if body? %>
<div class="px-4 grow">
<%= body %>
<% if sections.any? %>
<div class="space-y-4">
<% sections.each do |section| %>
<%= section %>
<% end %>
</div>
<% end %>
</div>
<% end %>
<%# Optional, for customizing dialogs %>
<%= content %>
</div>
<% if actions? %>
<div class="flex items-center gap-2 justify-end p-4">
<% actions.each do |action| %>
<%= action %>
<% end %>
</div>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>