Svelte Toast - Bitblue

Imperative toast notifications powered by svelte-french-toast with optional sound presets

Mount <Toaster /> once near the app root, then call toast() anywhere.

Setup

<script lang="ts">
	import { Toaster, toast, Button } from '.';
</script>

<Toaster />

Basic usage

Interactive toast triggers belong in example fences (client-side). Live page demos below call the same API from the docs script.

<script lang="ts">
	import { Button, toast } from '.';
</script>

<Button onclick={() => toast('Hello toast!')}>Default</Button>
<Button color="green" onclick={() => toast.success('Saved successfully')}>Success</Button>
<Button color="red" onclick={() => toast.error('Something went wrong')}>Error</Button>
<Button color="blue" onclick={() => toast.loading('Uploading…')}>Loading</Button>

Promise toast

<script lang="ts">
	import { Button, toast } from '.';

	function save() {
		const p = new Promise((resolve) => setTimeout(resolve, 1500));
		toast.promise(p, {
			loading: 'Saving…',
			success: 'Saved!',
			error: 'Failed to save'
		});
	}
</script>

<Button onclick={save}>Save with promise</Button>

With sound

<script lang="ts">
	import { Toaster } from '.';
</script>

<Toaster fireWithSound soundPreset="chime" />

Sound presets: chime, ding, bell, soft, pop, pulse, airy.

Composition notes

  • Render a single <Toaster /> at the app shell (docs pages mount one for demos).
  • Prefer toast.success / toast.error / toast.loading helpers; use toast.promise for async work.
  • updateToastConfig adjusts shared defaults (duration, sound) after mount.
  • Options follow svelte-french-toast ToastOptions (duration, position, icon, style, id, …).

Props

ToasterProps

PropTypeDefaultDescription
positionToastPositiontop-centerViewport placement
durationnumber4000Default ms before dismiss
toastOptionsDefaultToastOptions{}Defaults passed to french-toast
reverseOrderbooleanfalseNewest first vs last
gutternumber8Gap between toasts
containerStylestring—Inline style on container
containerClassNamestring—Class on container
fireWithSoundbooleanfalsePlay Web Audio on show
soundPresetchime | ding | bell | soft | pop | pulse | airychimeSound when enabled
classNamestring''Legacy no-op class
themeToastTheme{}Reserved theme bag
richColorsbooleanfalseRich color styling flag
customIconsbooleantrueUse custom icons
closeButtonbooleantrueShow close control
pauseOnHoverbooleantruePause timer on hover
visibleToastsnumber3Max visible stack
expandbooleanfalseExpand stacked toasts
gapnumber8Stack gap
offsetnumber | string'32px'Distance from edge

toast API

ExportSignatureDescription
toast(message, options?) => idShow a default toast
toast.success(message, options?) => idSuccess variant
toast.error(message, options?) => idError variant
toast.loading(message, options?) => idLoading variant
toast.promise(promise, msgs, opts?)Loading → success/error
toast.customfrench-toast customFully custom toast
toast.dismiss(id?)Dismiss one or all
toast.remove(id?)Remove without animation
updateToastConfig(config)Update shared duration / sound
originalToastfrench-toast instanceEscape hatch

Events

Toast is imperative — there are no component event props. Lifecycle is controlled via toast.dismiss / toast.remove and french-toast options (onClick, onClose where supported by the underlying library).


© 2026 Bitblue is a registered trademark. All Rights Reserved.