SDK reference
Dialogs
Copy page
Questions, popups, alerts and toasts in Lia's own style, over your app.
Dialogs open over your app in Lia's own style and language direction, and pause your app while they're open. One of Lia's screens shows at a time: while one is open, another fails with busy.
#Lia.confirm(options)
A yes or no question in Lia's own sheet.
const { confirmed } = await Lia.confirm({
title: "Start a new round?",
body: "Your score so far won't count.",
confirm: "Start over",
danger: true,
});| Option | Type | |
|---|---|---|
title | string | Required, up to 60 characters. |
body | string | Optional, up to 300 characters. |
confirm | string | Optional label for the yes button, up to 24 characters. Lia's own word when left out. |
danger | boolean | Optional. Shows the yes button as destructive. |
Resolves with { confirmed }, false however the sheet was closed without a yes. Errors: bad_title, bad_body, bad_confirm, busy.
#Lia.showPopup(params)
A message with up to three buttons. Resolves with the pressed button's id, or null if it was closed another way.
const choice = await Lia.showPopup({
title: "Save your game?",
message: "You can come back to it later.",
buttons: [
{ id: "save", type: "default", text: "Save" },
{ id: "delete", type: "destructive", text: "Delete" },
{ type: "cancel" },
],
});| Param | Type | |
|---|---|---|
title | string | Optional, up to 64 characters. |
message | string | Required, up to 256 characters. |
buttons | array | 1 to 3 buttons. One Close button when left out. |
Each button:
| Field | Type | |
|---|---|---|
id | string | What showPopup resolves with when it's pressed. Up to 64 characters; "" when left out. |
type | string | "default", "ok", "close", "cancel" or "destructive". |
text | string | Required for default and destructive, up to 64 characters. The others use Lia's own word when left out. |
Errors: bad_message, bad_title, bad_buttons, bad_button_type, bad_text, bad_id, busy.
#Lia.showAlert(message)
A message with one Close button. Resolves with nothing once it's closed.
await Lia.showAlert("Your progress is saved.");#Lia.showConfirm(message)
A message with OK and Cancel. Resolves with true when OK was pressed.
if (await Lia.showConfirm("Leave this match?")) leaveMatch();#Lia.toast(message, options)
A short message in Lia's own style that goes away by itself. It doesn't pause your app.
Lia.toast("Saved");
Lia.toast("No connection", { tone: "error", position: "top" });| Parameter | Type | |
|---|---|---|
message | string | Up to 140 characters. |
options.position | string | "bottom" (the default) or "top". |
options.tone | string | "info" (the default) or "error". |
Resolves with null. Errors: bad_text, bad_position.