sonner-svelte

An opinionated toast component for svelte

Github

Installation

npm install sonner-svelte

Usage

Render a toast on button click

<script>
import { toast, Toaster } from 'sonner-svelte';
</script>

<Toaster />
<button on:click={() => toast('My first toast')}>
  Give me a toast
</button>

Types

You can customize the type of toast you want to render, and pass an options object as the second argument.

toast('Event has been created')

Position

Swipe direction changes depending on the position.

<Toaster position="bottom-right" />

Expand

You can change the amount of toasts visible through the visibleToasts prop.

<Toaster expand={false} />

Other

toast.success('Event has been created')

// ...

<Toaster richColors  />