LiveToast
NewOverview
Installs LiveToast with its default presentation, programmatic notifications, streams, actions, and multiple containers.
<div class="flex flex-wrap justify-center gap-2">
<Button.button phx-click="show-live-toast" phx-value-kind="info">
Show LiveToast
</Button.button>
<Button.button
phx-click="show-live-toast"
phx-value-kind="error"
phx-value-title="Unable to save"
>
Show titled LiveToast
</Button.button>
</div>
Add this module
mix dizzy.add live_toast
This command also adds the LiveToast dependency, Tailwind source, and LiveSocket hook. Replace the existing flash group in your application layout with the Dizzy wrapper.
<DizzyLiveToast.toast_group
flash={@flash}
connected={assigns[:socket] != nil}
toasts_sync={assigns[:toasts_sync] || []}
/>
Component API
LiveToast.toast_group
Attributes
| Name | Type | Default | Values |
|---|---|---|---|
client_error_delay |
:integer
| 3000 | โ |
connected |
:boolean
| Required | โ |
connection_notifications |
:any
| %{} | โ |
corner |
:atom
| :bottom_right | :top_left, :top_center, :top_right, :bottom_left, :bottom_center, :bottom_right |
flash |
:map
| Required | โ |
flash_duration |
:integer
| 0 | โ |
id |
:string
| "toast-group" | โ |
kinds |
:list
| [:info, :error] | โ |
toast_component_fn |
:any
| nil | โ |
toasts_sync |
:list
| [] | โ |
Slots
| Name | Required |
|---|---|
client_error | Optional |
server_error | Optional |
JavaScript hook
LiveToast
Provided by the LiveToast package. It schedules, animates, and dismisses streamed notifications and coordinates client events with the LiveComponent. The Dizzy installer imports and registers it automatically.
mix dizzy.add includes the hook and performs
any required asset setup automatically.