AlertDialog
The interruption that requires a decision — no backdrop dismissal.
A Dialog that absorbs every outside click and Escape and offers exactly Cancel
and Action. Poll Confirmed/Cancelled each frame while open; lay it
out at window constraints like Dialog.
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-dialog
Usage
var confirm lotusui.AlertDialog
var open bool
if deleteBtn.Clicked(gtx) { open = true; confirm.Appear() }
if open {
if confirm.Confirmed(gtx) { open = false; doDelete() }
if confirm.Cancelled(gtx) { open = false }
confirm.Layout(th, gtx, lotusui.AlertDialogOpts{
Title: "Are you absolutely sure?",
Description: "This action cannot be undone. This will permanently delete your account.",
})
}
Destructive
Destructive: true turns the action red; Media renders a
medallion above the title; Size picks the width preset.
confirm.Layout(th, gtx, lotusui.AlertDialogOpts{
Size: lotusui.SizeSM, Title: "Delete chat?",
Description: "This will permanently delete this chat conversation.",
Action: "Delete", Destructive: true, Media: dangerMedallion,
})
Small
confirm.Layout(th, gtx, lotusui.AlertDialogOpts{
Size: lotusui.SizeSM, Title: "Allow accessory to connect?",
Description: "Do you want to allow the USB accessory to connect to this device?",
Cancel: "Don't allow", Action: "Allow",
})
API
| Option | Type | Description |
|---|---|---|
Appear() | method | Restart the entrance animation on the closed→open transition. |
Confirmed(gtx) / Cancelled(gtx) | bool | Poll each frame while open. |
Title / Description | string | The decision's copy. |
Cancel / Action | string | Button labels; empty = Cancel / Continue. |
Size | Size | Dialog width preset (Size2XS…Size2XL). |
Media | layout.Widget | Renders above the title — an icon medallion, an image. |
Destructive | bool | Renders the action destructively. |