Button component using el-dm-button custom element.
Provides four button modes:
- Standard button with variants and sizes
- Native submit button for forms that must work without JavaScript
- Button with confirmation modal (Invoker Commands API)
- Noise effect button (decorative)
When command / commandfor or interestfor are set, renders a native
<button> so the invoker APIs work (custom element hosts are not valid invokers).
Set native_submit to render a native <button type="submit"> without the
custom element runtime.
Pass aria-label for icon-only buttons or aria-labelledby to reference
labels in the same document. The custom element synchronizes these attributes
and changes to referenced labels with its native shadow button.
With confirm, interestfor, title, and accessible labels/descriptions
also reach the visible trigger. Caller styles stay on that trigger. LiveView
events, hooks, and form submission attributes stay on the confirmed action,
whose ID is #{id}-confirm. Labels are retained on the action as well;
tooltip targeting and anchor styles are not.
Examples
<.dm_btn>Click me</.dm_btn>
<.dm_btn variant="primary" size="lg">Primary</.dm_btn>
<.dm_btn variant="error" confirm="Are you sure?">Delete</.dm_btn>
<.dm_btn native_submit variant="primary">Save</.dm_btn>
<.dm_btn command="show-modal" commandfor="my-modal">Open</.dm_btn>
<.dm_btn noise content="SUBMIT">Submit</.dm_btn>
Summary
Functions
Generates a button.
Functions
@spec dm_btn(map()) :: Phoenix.LiveView.Rendered.t()
Generates a button.
Examples
<.dm_btn id="show-btn">Show</.dm_btn>
<.dm_btn variant="primary" size="lg">Primary Button</.dm_btn>
<.dm_btn navigate="/dashboard" variant="ghost">Dashboard</.dm_btn>
<.dm_btn native_submit variant="primary">Save</.dm_btn>
<.dm_btn confirm="Are you sure?" confirm_title="Confirm Action">Delete</.dm_btn>Attributes
id(:any) - HTML id attribute. Defaults tonil.class(:any) - Additional CSS classes. Defaults tonil.variant(:string) - Button color variant. Defaults tonil. Must be one ofnil,"primary","secondary","accent","info","success","warning","error","ghost","link", or"outline".size(:string) - Button size. Defaults tonil. Must be one ofnil,"xs","sm","md", or"lg".shape(:string) - Button shape. Defaults tonil. Must be one ofnil,"square", or"circle".loading(:boolean) - Show loading state. Defaults tofalse.disabled(:boolean) - Disable the button. Defaults tofalse.native_submit(:boolean) - Render a native submit button for forms that must work without JavaScript. Defaults tofalse.navigate(:string) - Navigates from a LiveView to a new LiveView. Defaults tonil.patch(:string) - Patches the current LiveView. Defaults tonil.href(:any) - Uses traditional browser navigation to the new location. Defaults tonil.replace(:boolean) - Replace browser history when using navigate or patch. Defaults tofalse.noise(:boolean) - Use noise effect button style. Defaults tofalse.content(:string) - Content text for noise button. Defaults to"".confirm(:string) - Confirmation message (enables confirm modal). Defaults to"".confirm_title(:string) - Title for confirmation modal. Defaults to"".confirm_text(:string) - Text for the confirm button in modal. Defaults to"Yes".cancel_text(:string) - Text for the cancel button in modal. Defaults to"Cancel".confirm_class(:any) - CSS class for confirm button. Defaults tonil.cancel_class(:any) - CSS class for cancel button. Defaults tonil.show_cancel_action(:boolean) - Show cancel button in modal. Defaults totrue.confirm_label(:string) - Accessible fallback label for confirm modal when no title is set (i18n). Defaults to"Confirmation".- Global attributes are accepted. Additional HTML attributes. Supports all globals plus:
["phx-click", "phx-target", "phx-value-id", "phx-disable-with", "name", "value", "type", "form", "command", "commandfor", "interestfor"].
Slots
inner_block(required) - Button content.prefix- Content before button text (e.g., icon).suffix- Content after button text (e.g., icon).confirm_action- Custom confirm action button content.