Corex.Flash (Corex v0.1.0-rc.0)

View Source

Configuration for Phoenix flash messages rendered as Zag toasts.

Used by Corex.Toast.toast_group/1 via the flash_info and flash_error attributes. When flash={@flash} is set on the layout toaster, :info and :error entries from Phoenix.Flash become toasts with titles and durations from these structs (or equivalent maps).

If you omit flash_info / flash_error, Corex.Toast.Translation supplies default titles and a 5000 ms duration.

Example

<.toast_group
  id="layout-toast"
  class="toast"
  flash={@flash}
  flash_info={%Corex.Flash.Info{title: "Saved", type: :success, duration: 5000}}
  flash_error={%Corex.Flash.Error{title: "Problem", type: :error, duration: :infinity}}
>
  <:loading>
    <.heroicon name="hero-arrow-path" />
  </:loading>
  <:close>
    <.heroicon name="hero-x-mark" />
  </:close>
</.toast_group>

Plain maps with the same keys (:title, :type, :duration) are also accepted.