Toast
Transient notifications: bottom-right stack, auto-dismissing.
Toaster owns the queue: Add from anywhere, Layout ONCE
per frame at window constraints (the same portal rule as Dialog). Each toast dismisses after
its duration; destructive toasts carry danger ink.
Installation
Use the module import (the default), or own the source: lotusui add
vendors the component into your app and lotusui update keeps the copy mergeable —
see Registry.
go get github.com/ikaito-com/lotusui
# or vendor the source into your app:
go run github.com/ikaito-com/lotusui/cmd/lotusui add toast
Usage
var toaster lotusui.Toaster // one per window
if saved { toaster.Add(lotusui.Toast{Title: "Event has been created"}) }
// at the END of your window's frame:
toaster.Layout(th, gtx)
Types
Success, info and warning color the title's ink; destructive colors everything.
toaster.Add(lotusui.Toast{Variant: lotusui.ToastSuccess, Title: "Event has been created"})
toaster.Add(lotusui.Toast{Variant: lotusui.ToastInfo, Title: "Arrive 10 minutes before the event"})
Promise
The in-flight pattern: Add a Loading toast under an
ID, then Update the same ID with the outcome — it replaces in place
and restarts the clock.
toaster.Add(lotusui.Toast{ID: "create", Loading: true, Title: "Creating event…", Duration: time.Minute})
// …when the work completes:
toaster.Update("create", lotusui.Toast{Variant: lotusui.ToastSuccess, Title: "Event created."})
API
| Option | Type | Description |
|---|---|---|
Toaster.Add(Toast) | method | Enqueue from anywhere; safe during event handling. |
Toaster.Update(id, Toast) | method | Replace the live toast with that ID in place — the promise pattern. |
Toast.Title / Description | string | The notification's copy. |
Toast.Variant | ToastVariant | ToastDefault, ToastDestructive, ToastSuccess, ToastInfo, ToastWarning. |
Toast.ID | string | Names the toast for Update. |
Toast.Loading | bool | A spinner before the title. |
Toast.Duration | time.Duration | Auto-dismiss delay; zero means 4s. |