Toast
Temporary notification messages. Can be flash-based or programmatic.
Programmatic Toast
Flash-based Toasts
Toasts can also be triggered via Phoenix flash messages. The toast container
automatically displays
:info
and
:error
flash messages.
# In your LiveView:
{:noreply, put_flash(socket, :info, "Operation completed!")}
Programmatic Toasts
For more control, use
push_event/3
to show toasts
programmatically:
push_event(socket, "toast", %{
variant: "success", # "default", "success", or "destructive"
title: "Success!",
description: "Your changes have been saved.",
duration: 5000 # milliseconds, 0 = no auto-dismiss
})
Notes
- Flash-based toasts are cleared on navigation or when dismissed.
-
Programmatic toasts auto-dismiss after the specified duration.
Set
duration: 0to disable auto-dismiss. -
Toasts use
role="status"andaria-live="polite"for accessibility.