papi-dts
    Preparing search index...

    Data needed to display a notification to the user

    interface PlatformNotification {
        clickCommand?: keyof CommandHandlers;
        clickCommandLabel?: string;
        dismissClickCommand?: keyof CommandHandlers;
        dismissible?: boolean;
        duration?: number;
        message: string;
        notificationId?: string | number;
        position?:
            | "top-left"
            | "top-right"
            | "bottom-left"
            | "bottom-right"
            | "top-center"
            | "bottom-center";
        secondaryClickCommand?: keyof CommandHandlers;
        secondaryClickCommandLabel?: string;
        severity: Severity;
    }
    Index

    Properties

    clickCommand?: keyof CommandHandlers

    Optional command to run if users click on the label in the notification. The command will be sent one argument:

    • NotificationId: The ID of the notification that was clicked

    The command handler should have the type signature NotificationClickCommandHandler.

    clickCommandLabel?: string

    Optional label for users to click when the notification shows. Always rendered as the notification's PRIMARY action button - the visually emphasized one - while secondaryClickCommandLabel always gets the muted secondary styling.

    Automatically localized if this is a LocalizeKey.

    dismissClickCommand?: keyof CommandHandlers

    Optional command to run if the user dismisses the notification themselves - by swiping/dragging it away, or by clicking the close button (if the host ever enables one). Sent no arguments other than the notification id, like clickCommand:

    • NotificationId: The ID of the notification that was dismissed

    The command handler should have the type signature NotificationClickCommandHandler.

    IMPORTANT: this fires when the user dismisses the notification themselves (swiping/dragging it away, or clicking a close button if the host ever enables one) AND when the notification auto-closes because its duration elapsed - a timeout is treated as an implicit dismissal, so a must-answer toast that times out still runs this command instead of vanishing silently. It does NOT fire when the notification is dismissed programmatically via INotificationService.dismiss, nor when the user clicks clickCommand / secondaryClickCommand. Use this to treat a swipe-away (or timeout) as an explicit decision - e.g. pairing it with a "postpone" command lets a two-button, must-answer-style toast keep dismissible true (see the warning on dismissible). If you need the toast to persist until the user actually answers, also set duration to 0.

    dismissible?: boolean

    Whether the user can dismiss the notification directly (e.g. by swiping/dragging it away, or via a close button). Defaults to true.

    The host toast library (Sonner) gates both the secondaryClickCommand button and the user-dismiss gesture that fires dismissClickCommand on this same flag, so a naive dismissible: false would silently turn those controls into dead buttons. To prevent that, the platform IGNORES dismissible: false when the notification renders a secondary action button (a secondaryClickCommand paired with its secondaryClickCommandLabel) or has a dismissClickCommand - the notification stays user-dismissible so those controls keep working. dismissible: false therefore only takes effect on a notification with no secondary button and no dismiss command. For a notification the user must explicitly answer, prefer leaving dismissible: true and using dismissClickCommand so a swipe-away still counts as a real (e.g. "postpone") decision.

    NOTE: dismissible: false does not keep the notification on screen. Auto-close is governed solely by duration (when omitted, 10-35 seconds computed from message length), so a non-dismissible notification still auto-closes on that timer. Also set duration to 0 (or less) if the notification must stay up until it is answered or programmatically dismissed via INotificationService.dismiss.

    duration?: number

    Optional duration in milliseconds for how long the notification is displayed. To make the notification show indefinitely, specify a duration of 0 or less.

    When omitted, duration is computed from message length (minimum 10 seconds, maximum 35 seconds).

    message: string

    Text to display to the user.

    Automatically localized if this is a LocalizeKey.

    notificationId?: string | number

    Optional ID of a previous notification to update instead of showing a new notification.

    On an update (a send reusing an id that is still showing), any optional field you omit keeps the value it had on the previous send for that id - omitting a field never clears it. Pass the field explicitly to change it.

    position?:
        | "top-left"
        | "top-right"
        | "bottom-left"
        | "bottom-right"
        | "top-center"
        | "bottom-center"

    Optional placement of the notification on screen. When omitted, the app's default placement is used.

    secondaryClickCommand?: keyof CommandHandlers

    Optional command to run if users click on the secondary label in the notification. Like clickCommand, the command is sent one argument:

    • NotificationId: The ID of the notification that was clicked

    The command handler should have the type signature NotificationClickCommandHandler.

    secondaryClickCommandLabel?: string

    Optional label for a second action button, shown alongside clickCommandLabel. Provide this together with secondaryClickCommand to give the notification two actions.

    Always rendered as the visually SECONDARY button (muted styling, like the shadcn secondary button variant) so the clickCommandLabel button keeps the emphasis - the platform decides each button's styling from which field it came from, never from ordering.

    Automatically localized if this is a LocalizeKey.

    severity: Severity

    Severity of the notification