show_toast

Display toast notifications

show_toast

Displays a toast notification to the user.

Syntax

json
{
  "type": "show_toast",
  "message": "Operation completed!",
  "level": "success"
}

Properties

PropertyTypeRequiredDescription
messagestringYesNotification message
levelstring-Toast level (default: info)
titlestring-Toast title
durationnumber-Display duration (ms)
actionobject-Action button

Levels

LevelColorUse Case
infoBlueGeneral information
successGreenSuccess confirmations
warningYellowWarnings
errorRedError messages

Examples

Basic toast:

json
{
  "type": "show_toast",
  "message": "Settings saved"
}

Success toast:

json
{
  "type": "show_toast",
  "message": "Item created successfully!",
  "level": "success"
}

Error toast:

json
{
  "type": "show_toast",
  "message": "Failed to save changes",
  "level": "error"
}

Warning toast:

json
{
  "type": "show_toast",
  "message": "Your session will expire in 5 minutes",
  "level": "warning"
}

With title:

json
{
  "type": "show_toast",
  "title": "Success",
  "message": "Your profile has been updated",
  "level": "success"
}

With duration:

json
{
  "type": "show_toast",
  "message": "Copied to clipboard",
  "level": "success",
  "duration": 2000
}

With dynamic message:

json
{
  "type": "show_toast",
  "message": "Welcome back, {{state.user.name}}!",
  "level": "success"
}

From error response:

json
{
  "type": "call_api",
  "api": "saveData",
  "on_error": [
    {
      "type": "show_toast",
      "message": "Error: {{$error.message}}",
      "level": "error"
    }
  ]
}

Common Patterns

CRUD Operations:

json
{ "type": "show_toast", "message": "Item created", "level": "success" }
{ "type": "show_toast", "message": "Changes saved", "level": "success" }
{ "type": "show_toast", "message": "Item deleted", "level": "success" }
{ "type": "show_toast", "message": "Operation failed", "level": "error" }

Copy to clipboard:

json
{
  "type": "Button",
  "icon": "Copy",
  "events": {
    "on_click": [
      { "type": "copy", "text": "{{state.shareUrl}}" },
      { "type": "show_toast", "message": "Link copied!", "level": "success", "duration": 2000 }
    ]
  }
}

After navigation:

json
{
  "on_mount": [
    {
      "type": "conditional",
      "condition": "{{params.created}}",
      "then": [
        { "type": "show_toast", "message": "Item created successfully!", "level": "success" }
      ]
    }
  ]
}

Best Practices

  1. Be concise - Keep messages short and clear
  2. Use appropriate levels - Match level to message importance
  3. Confirm actions - Show success after operations
  4. Include details in errors - Help users understand what went wrong
  5. Don’t overuse - Avoid toast fatigue