Persistent inline notice with colour, variant, shape, accent stripe, actions and a close button.
<.alert color="warning" variant="soft">
<:icon><.icon name="alert" /></:icon>
<div class="t"><b>Certificate expires in 12 days</b><span>Renew it to keep issuing.</span></div>
<:action><button class="lu-b c-warning v-soft s-xs sh-rounded" type="button">Renew</button></:action>
</.alert>
<.alert id="saved" color="success" dismissible on_dismiss="hide_notice">Changes saved.</.alert>A short notice can use title and description instead:
<.alert color="warning" title="Certificate expires" description="Renew it." />. The content is yours: write <div class="t"><b>Title</b><span>Text</span></div> for the
title-plus-line layout. The close button hides the alert in the browser (no round trip) and, with
on_dismiss, tells the server (%{"id" => id}). dismiss_alert/1 does the same for a
button placed by hand: <button phx-click={dismiss_alert()}>Later</button>.
Summary
Functions
JS command that fades out and hides the alert around the element that runs it.
Functions
Attributes
id(:string) - Defaults tonil.color(:string) - Defaults to"neutral". Must be one ofnil,"neutral","primary","secondary","info","success","warning","error", or"dark".variant(:string) - Defaults to"canvas". Must be one ofnil,"canvas","solid","outline","soft", or"bordered".shape(:string) - Defaults to"rounded". Must be one of"rounded", or"pill".accent(:any) - The colored stripe:top(or justaccent),left,right. Defaults tonil. Must be one ofnil,"",true,"top","left", or"right".description(:string) - The line under the title (title="..."): written as<div class="t"><b>title</b><span>description</span></div>. Defaults tonil.dismissible(:boolean) - Defaults tofalse.on_dismiss(:any) - Event name or%JS{}run when the alert is closed. Defaults tonil.target(:any) -phx-targetofon_dismiss. Defaults tonil.close_label(:string) - Defaults to"Close".open(:boolean) - Defaults totrue.class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
action- Controls after the content.icon- Icon before the content. Accepts attributes:boxed(:boolean)
inner_block
@spec dismiss_alert(Phoenix.LiveView.JS.t()) :: Phoenix.LiveView.JS.t()
JS command that fades out and hides the alert around the element that runs it.
<button phx-click={dismiss_alert()}>Remind me later</button>