Modal dialog component using the native HTML <dialog> element and
@duskmoon-dev/core dialog CSS.
Open and close with the Invoker Commands API (command / commandfor).
The client-owned open attribute is preserved across LiveView patches.
Examples
<.dm_modal id="my-modal">
<:trigger :let={id}>
<.dm_btn variant="primary" command="show-modal" commandfor={id}>Open</.dm_btn>
</:trigger>
<:title>PhoenixDuskmoon</:title>
<:body>Modal content here</:body>
<:footer>
<.dm_btn command="close" commandfor="my-modal">Close</.dm_btn>
</:footer>
</.dm_modal>
Summary
Functions
Renders a modal dialog.
Functions
Renders a modal dialog.
Examples
<.dm_modal id="my-modal">
<:trigger :let={id}>
<button type="button" command="show-modal" commandfor={id}>Open</button>
</:trigger>
<:title>Modal Title</:title>
<:body>Modal body content</:body>
</.dm_modal>Attributes
id(:any) - Modal id.class(:any) - Additional CSS classes. Defaults tonil.hide_close(:boolean) - Hide the close button. Defaults tofalse.position(:string) - Modal position (top / bottom; middle is default centered). Defaults tonil. Must be one ofnil,"top","middle", or"bottom".size(:string) - Modal size (sm / lg / xl map to core classes; xs and md use default width). Defaults tonil. Must be one ofnil,"xs","sm","md","lg", or"xl".close_label(:string) - Accessible label for the close button. Defaults to"Close".dialog_label(:string) - Accessible fallback label when no title slot is provided (i18n). Defaults to"Dialog".phx-mounted(Phoenix.LiveView.JS) - additional LiveView JS commands composed before preserving the open attribute. Defaults to%Phoenix.LiveView.JS{ops: []}.- Global attributes are accepted.
Slots
trigger- Element that opens the modal. Accepts attributes:class(:any) - trigger wrapper CSS classes.
title- Modal title. Accepts attributes:class(:any) - title container CSS classes.
body(required) - Modal content. Accepts attributes:class(:any) - body container CSS classes.
footer- Modal footer with actions. Accepts attributes:class(:any) - footer container CSS classes.