1. integrations
  2. toasts
  3. svelte

Toasts

Display small notifications pinned to the edge of the screen.

This feature is currently available as an early access Beta preview, meaning the features and API are not yet stable. This feature is not yet recommended for production use as breaking changes may occur. Please use this feature with caution.

Setup the Provider

Wrap the contents of your app with ToastProvider in your root layout. We’ll interface with this using the Svelte Context API.

+layout.svelte
<script lang="ts">
import { ToastProvider } from '@skeletonlabs/skeleton-svelte';
</script>
<ToastProvider>
{@render children()}
</ToastProvider>

Create a Toast

There are three available types of toasts: info | error | success, with info being the default.

API Reference

ToastProvider

The list of available component props.

  • placement?: 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end'; (default bottom-end)
  • offset?: string; - Offset from the viewport edge. (default: 16px)
  • dismissLabel?: string; - The dismiss button label text. (default &times;)

Toast

Supply these values within toast.create().

  • title?: string; - The unique toast title text.
  • description: string; - The unique toast description text.
  • type?: 'info' | 'error' | 'success'; - Define the toast type. (default info)
  • duration?: number; - The duration of the toast. Default varies by type.