LineOne's alerts: filled, outlined, soft and bordered, with an icon, an accent bar or a close button.
<.alert>This is simple alert</.alert>
<.alert color="primary" variant="soft" shape="pill">Saved</.alert>
<.alert color="secondary" variant="soft" accent="left">With a bar</.alert>
<.alert color="info" variant="outline">
<:icon boxed><svg>…</svg></:icon>
This is simple alert
</.alert>
<.alert id="notice" color="info" variant="outline" dismissible>Closable</.alert>dismiss_alert/1 fades out and hides the alert around the element that runs it, for close
buttons placed by hand:
<.button phx-click={dismiss_alert()}>Remind me later</.button>
Summary
Functions
Renders an alert.
Fades out and hides the alert that holds the element running it, the way LineOne removes a dismissed alert.
Functions
Renders an alert.
With accent or a boxed :icon the alert is split into parts and its padding moves to the
content; otherwise the content sits in the padded alert itself, after an inline icon.
<.alert id="saved" color="success" variant="soft" dismissible on_dismiss="hide_notice">
<:icon><svg class="size-5">…</svg></:icon>
Changes saved.
</.alert>With on_dismiss="hide_notice" the server gets handle_event("hide_notice", %{"id" => "saved"}, socket).
Attributes
id(:string) - Defaults tonil.color(:string) - Defaults to"neutral". Must be one of"neutral","primary","secondary","info","success","warning","error", or"dark".variant(:string) - Defaults to"solid". Must be one of"solid","outline","soft", or"bordered".shape(:string) - Defaults to"rounded". Must be one of"rounded", or"pill".accent(:string) - A colored bar on one side of the alert. Defaults tonil. Must be one ofnil,"left", or"right".dismissible(:boolean) - Adds LineOne's close button, which fades the alert out. Defaults tofalse.on_dismiss(:any) - An event name or aJScommand run when the close button is pressed. The event's payload is%{"id" => id}. Defaults tonil.target(:any) - Thephx-targetofon_dismiss. Defaults tonil.open(:boolean) -falserenders the alert hidden; the close button hides it in the browser. Defaults totrue.class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
icon- An icon before the content. Accepts attributes:boxed(:boolean) - Draws the icon on a filled block at the edge of the alert.
action- Controls after the content, such as a menu or a button.inner_block(required)
@spec dismiss_alert(Phoenix.LiveView.JS.t()) :: Phoenix.LiveView.JS.t()
Fades out and hides the alert that holds the element running it, the way LineOne removes a dismissed alert.
<button phx-click={dismiss_alert()}>Close</button>