Toast
NewOverview
Stackable toast notifications with Phoenix flash fallback, titles, four severity levels, and automatic dismissal.
<div class="flex flex-wrap justify-center gap-2">
<Button.button phx-click="show-toast" phx-value-kind="success">
Show toast
</Button.button>
<Button.button phx-click="show-toast" phx-value-kind="warning" phx-value-title="Check this">
Show titled toast
</Button.button>
</div>
Individual toast
Topic published
Your topic is now visible to the community.
<Toast.toast
id="toast-example-notification"
kind={:success}
title="Topic published"
message="Your topic is now visible to the community."
duration={0}
/>
Add this module
mix dizzy.add toast
Add on_mount MyAppWeb.Ui.Toast
to your web moduleβs live_view/0
quote, then replace the existing flash group in your application layout.
<Toast.toast_group
flash={@flash}
toasts={assigns[:toasts] || []}
/>
Component API
Toast.toast_group
Attributes
| Name | Type | Default | Values |
|---|---|---|---|
duration |
:integer
| 5000 | β |
flash |
:map
| Required | β |
id |
:string
| "toast-group" | β |
toasts |
:list
| [] | β |
Toast.toast
Attributes
| Name | Type | Default | Values |
|---|---|---|---|
duration |
:integer
| Required | β |
id |
:string
| Required | β |
is_flash |
:boolean
| false | β |
kind |
:atom
| Required | :info, :success, :warning, :error |
message |
:string
| Required | β |
rest |
:global
| nil | β |
title |
:string
| nil | β |
JavaScript hook
.DizzyToastAutoDismiss
Starts the automatic dismissal timer and clicks the same dismissal control used manually. Phoenix JS commands handle enter and exit transitions, flash cleanup, and optimistic hiding.
mix dizzy.add includes the hook and performs
any required asset setup automatically.