Toast

A brief notification that appears temporarily to inform users of an action or event.

Anatomy

<script>
  import { Toaster, createToaster } from "@saas-ui/svelte/components/toast";

  const toaster = createToaster({ placement: "top-end" });
</script>

<button
  onclick={() => toaster.create({
    title: "Toast title",
    description: "Toast description",
    status: "success",
  })}
>
  Show Toast
</button>

<Toaster {toaster} />

Examples

Basic Accessibility

Basic toast triggered by a button.

Default Accessibility

Static toast preview without toaster.

Duration Accessibility

Toast with different duration values.

Stacking Accessibility

Multiple toasts stacking.

Status Accessibility

Toast with different status types.

With Action Accessibility

Toast with an action button.

Props

Toast

The toast notification component that displays a message.

Prop Type Default Description
class string - Additional CSS classes to apply.
status "info" | "success" | "warning" | "error" | "loading" "info" The status/type of the toast notification.
icon boolean | Component - Custom icon component, or false to hide the icon.
title string - The title text of the toast.
description string - The description text of the toast.
action { label: string; onClick?: () => void } - An action button to display in the toast.
closable boolean true Whether the toast can be dismissed.
onclose () => void - Callback invoked when the toast is closed.
children Snippet - Custom content to render inside the toast.

Toaster

The container component that renders and manages toast notifications from a toaster store.

Prop Type Default Description
toaster ToasterStore - The toaster store instance created by createToaster().
class string - Additional CSS classes to apply.

createToaster

A function that creates a toaster store for managing toast notifications.

Prop Type Default Description
placement "top" | "top-start" | "top-end" | "bottom" | "bottom-start" | "bottom-end" "bottom-end" The placement of the toast notifications.
duration number 5000 The default duration in milliseconds before toasts auto-dismiss.
gap number - The gap between stacked toasts.
overlap boolean - Whether toasts should overlap.