Skip to main content

Page Action | Toast

Use page.toast() to display a temporary toast notification to the user. This is particularly useful for displaying messages to the user that are not critical and do not require user interaction.

async function onClickDeleteCompany(companyId) {
const companyName = companies[companyId].name;
await db.company.deleteById(companyId);

page.toast(`${companyName} was successfully deleted`);
}

API reference

Function signature

page.toast(
message: string,
properties?: Partial<{
title: string,
appearance: "success" | "info" | "warning" | "error",
duration: "shortest" | "short" | "medium" | "long" | "longest" | "infinite"
}>): void

Parameters

message

required string
The message to display in the toast notification.

properties.title

optional string
An optional title for the toast notification. If provided, it will be displayed above the message.

properties.appearance

optional string literal

Sets the visual style of the toast. Defaults to "info".

Options:

  • "success": Use for successful operations
  • "info": Use for general information
  • "warning": Use for warnings
  • "error": Use for errors or destructive actions

properties.duration

optional string literal

Determines how long the toast will be displayed before disappearing. Defaults to "medium".

Options:

  • "shortest": 1.5 seconds
  • "short": 3 seconds
  • "medium": 5 seconds
  • "long": 10 seconds
  • "longest": 20 seconds
  • "infinite": 1000 seconds

Returns

void