Svelte
HelperSvelte ships Toaster.svelte plus toast / custom fromalert-notify/svelte/toast. For a live demo and install snippet, see the Svelte landing.
<script>
import Toaster from "alert-notify/svelte";
import { toast, custom } from "alert-notify/svelte/toast";
import Icon from "./Icon.svelte";
</script>
<Toaster position="top-right" richColors />
<button onclick={() => toast.success("Saved")}>Save</button>
<button
onclick={() =>
toast.info("Pay with card", {
icon: { component: Icon, props: { name: "card" } },
})
}
>
With icon
</button>Custom Svelte content
import { custom } from "alert-notify/svelte/toast";
import Panel from "./Panel.svelte";
custom({ component: Panel, props: { title: "Hello" } }, { autoClose: false });- Peer dependency: svelte >= 5.
- Keep using core
toast.custom(el)for plain DOM nodes. - Landing page: /svelte