Alert
The static callout: icon, title, description — it informs, never acts.
A bordered, tinted box with an icon, a title and an optional description. For interruptions that require action, use AlertDialog.
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 alert
Usage
lotusui.Alert(th, lotusui.AlertOpts{
Title: "Heads up!",
Description: "You can vendor any component into your app with the CLI.",
})
Destructive
Danger ink on the danger tint; the icon defaults to the warning glyph.
lotusui.Alert(th, lotusui.AlertOpts{
Variant: lotusui.AlertDestructive,
Title: "Your session has expired",
})
With action
Action renders at the alert's end — typically a small button.
lotusui.Alert(th, lotusui.AlertOpts{
Title: "Dark mode is now available",
Description: "Enable it under your profile settings to get started.",
Action: lotusui.Button(th, &enable, "Enable", lotusui.ButtonOpts{Size: lotusui.SizeXS}),
})
Colors
Color re-tints the whole alert from any ColorScale, the
pastel way — tinted well, deep same-hue ink, readability preserved by construction.
lotusui.Alert(th, lotusui.AlertOpts{
Color: lotusui.Orange,
Title: "Your subscription will expire in 3 days.",
})
API
| Option | Type | Description |
|---|---|---|
Variant | AlertVariant | AlertDefault, AlertDestructive. |
Icon | string | Overrides the variant's default (info / warning). |
Title / Description | string | Description optional. |
Action | layout.Widget | Rendered at the end — typically a small Button. |
Color | ColorScale | Re-tints the alert the pastel way from any scale. |