Toast is a notification effect returned by an action. It displays a transient message; it is not mounted in the component tree.
Payload¶
sdk.effects.notify(
"toast",
{
"title": "Saved",
"text": "The record was saved.",
"variant": "success",
"duration": 2600,
},
)| Field | Type | Description |
|---|---|---|
title |
str |
Short notification title. |
text |
str |
Body text. Web also accepts this as the main message text. |
variant |
str |
Visual type. The test page uses info, success, warning, error, danger, and default. |
duration |
int |
Display duration in milliseconds. |
Trigger¶
sdk.ui.Button(
"toast_success",
"Success",
action="components.test_effect_toast",
params={"variant": "success"},
variant="success",
icon="ric.checkbox-circle-line",
)- kind: Button
id: toast_success
label: Success
action: components.test_effect_toast
params: {variant: success}
variant: success
icon: ric.checkbox-circle-lineAction¶
@action("test_effect_toast")
async def test_effect_toast(ctx: dict, session: dict, sdk) -> dict:
variant = str(ctx.get("variant") or "info")
return sdk.effects.respond(
sdk.effects.notify(
"toast",
{
"title": f"{variant.title()} toast",
"text": f"Triggered with variant={variant}.",
"variant": variant,
"duration": 2600,
},
)
)Behavior¶
- Web maps
success,error/danger,warning, andinfoto Sonner toast types. - Desktop displays
success,warning,error/destructive, and the default informational style. dangeris useful as an authoring alias for destructive actions; web maps it to an error toast.