Overlays Core Stable

Toast

A notification system: call toast() from anywhere to queue one, mount <Toaster /> once to render the stack — success, error, info and loading variants, an optional action, and accessible live-region announcements

Preview

Installation

pnpm add fancy-ui-svelte
import { Toast } from 'fancy-ui-svelte'

Usage

svelte
<script lang="ts">
  import { Toast } from 'fancy-ui-svelte';
</script>

<Toast />

Examples

Basic Usage

Call toast() from a click handler; <Toaster /> renders the result.

Variants

Success, error, info and loading, side by side.

With Action

An error toast carrying a Retry action.

Persistent

duration: Infinity — dismissed only by the user, never automatically.

Props

PropTypeDefaultDescription
position "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right""bottom-right"Corner (or edge-center) the <Toaster /> stack anchors to
class string-Additional classes for the viewport that stacks the toasts
ref HTMLDivElement | nullnullBindable reference to the <Toaster /> root node
toast().title *string-Primary line of the toast raised by the toast() function
toast().description string-Secondary line, shown under the title
toast().variant "success" | "error" | "info" | "loading""info"Icon, accent colour, and the live region it announces through — error is assertive, everything else polite
toast().duration number5000Milliseconds before auto-dismiss; Infinity is sticky. Defaults to Infinity for the loading variant, which has no natural finish time
toast().action { label: string; onClick: () => void }-A single action button. Auto-dismiss pauses on hover or focus for every toast, with or without one