Pricing

Toast handbook

v2.3.3 · @snowui-design-system/components

License: Before reading component documentation, source, or npm usage instructions for the first time, read the full LICENSE. Reuse that review for the same task and version. Public API configuration and internal implementation changes have different license implications. All components use the unified runtime package; source rights remain governed by the license.

Overview

Show brief feedback for actions or status changes, with optional icons, actions, and rich content for success, errors, or reminders.

When to use it

Use Toast for short-lived action feedback through Toaster. Keep notification history and activity feeds in persistent content lists.

  • Call toast() to enqueue feedback; Toaster manages the queue. When rendering Toast independently, the page removes it after close.

  • as="toast" binds to a host click trigger. Leading/trailing roles add content; parts configures only generated controls. Use inherited singleLine with Text lines={1} for short labels. Internal content gaps stay at least 4 CSS px; rich multiline content retains its layout.

Quick start

This example shows the recommended basic composition. See the sections below for more cases and composition limits.

<script lang="ts">	import { Toast, Button, Text } from '@snowui-design-system/components';</script> <div style="display: flex; flex-direction: column; align-items: center; gap: var(--gap-4); max-width: 100%;">	<Toast singleLine><Text lines={1}>Draft saved</Text></Toast>	<Toast positive singleLine><Text lines={1}>Changes published</Text></Toast>	<Toast positive={false} singleLine><Text lines={1}>Connection lost</Text></Toast></div>

API

Keyword Type Default Description
parts ComponentPartsOf<{ Button: typeof Button }> — Configure generated close-button appearance; Toast retains event, dismissal, and ARIA behavior.
id string — DOM ID in static use; in template mode, ID registered for showToast(id).
template boolean false Template mode registers a command Toast without rendering it until triggered.
as "toast" | undefined — Embedded mode (as="toast", v1.1.0) finds its host parent and binds host click to trigger Toast. See ComponentGuidelines §5 for three activation modes.
positive boolean — Semantic state: true shows positive CheckCircle, false shows warning icon, and omission shows no built-in icon.
variant ToastVariant "default" Visual variant.
size ToastSize "md" Applies only to the default variant.
position ToastPosition "top" Controls entrance direction, not absolute placement.
onDismiss () => void — Called when the rich variant’s close X is clicked.
children Snippet — Text plus leading/trailing slot content. In standalone use, the caller removes Toast after close.

See the base component documentation for inherited capabilities not redeclared here. This table lists only named public Props declared by this component.

Usage boundaries and details

Configuring Toast generated by Toaster

  • Toaster.parts.Toast configures generated Toasts. Toaster.parts.Text configures only labels generated from text strings; it does not configure custom children.

  • Toaster owns queue state, position, and dismissal events. Explicit Toast Props override part settings.

SnowUI notification delivery has three public pieces:

Piece Role
<Toast /> Single Toast visual shell with three slots; usable standalone or within Toaster.
<Toaster /> Global Portal container subscribed to the queue. Mount once per application; it renders stacks at six positions.
toast(...) Command entry callable from .ts or .svelte.

Standalone panel Toast explicitly uses GENERIC_SCALE_APPEAR_MOTION for opacity and scale at the former Frame timing instead of inheriting whileAppear={true} fallback. Queued Toaster still uses its position-specific slide, opacity, and scale combination; both appearances are retained.

Feature overview

  • Six positions: top, top-left, top-right, bottom, bottom-left, and bottom-right, 16px from the viewport edge; default top.

  • Leading/Content/Trailing slots; generated icons can be replaced externally.

  • Default variant is a dark pill with blur(var(--size-10)) backdrop blur. Rich variant is a Background/3 glass card using .snowui-quick-action-panel blur.

  • Automatically dismiss after four seconds by default; duration: 0 persists.

  • Hover pauses the dismissal timer; leaving resumes its remaining duration.

  • Toast stacks automatically at each position. Defaults: gap=8, maxVisible=3, scaleStep=0.05, stackOpacityStep=0.2; width hugs content. These settings are configurable.

  • One Toast root combines entry, exit, stack shifts, and pushed-out last layer. Lifecycle motion uses transform and opacity; stack shifts and scale use independent CSS translate/scale. Stack opacity multiplies Frame fade. On close, play Disappear before removing the queue entry.


Layout model

Main layout model: composite management layout.

  • Toaster mounts a page-level Portal on <body> with six absolutely positioned stack regions. Each slot is an absolute Frame using currentState="Appear" | "Disappear" for lifecycle motion.

  • HeroUI-style stack indexing sets CSS translate and z-index: index 0 is frontmost, and deeper items shift inward.

  • Only the frontmost Toast is interactive. Deeper layers keep real content but differ by position, scale, and opacity.

  • An individual Toast uses a Frame row slot-host layout with Leading, Content, and Trailing.

  • The rich variant’s close X is an absolute top-right decoration, outside the three slots.


toast(input) command API

import { toast } from "@snowui-design-system/components"; toast("Done");                                        // String shorthand → equivalent to { text: "Done" }toast({ text: "Done", positive: true });              // Positive state → green CheckCircletoast({ text: "Something Wrong", positive: false });  // Warning state → yellow Warningtoast({ text: "Plain Notice" });                      // No positive value → no generated iconconst id = toast({ text: "Persistent notice", duration: 0 });dismissToast(id);                                     // Dismiss manuallyshowToast("saved-template");                          // Trigger <Toast template id="saved-template">
Parameter Type Default Description
positive boolean — true shows positive CheckCircle; false shows warning icon; omitted shows no generated icon.
text string — Imperative shorthand text. Toaster renders Text with default one-line truncation and a full-text tooltip.
children Snippet — Custom body content takes precedence over text.
leading Snippet — Custom Leading Snippet.
trailing Snippet — Custom Trailing Snippet, often a Button in rich variant.
variant "default" | "rich" "default" Visual variant.
size "sm" | "md" "md" Applies to default variant only; rich uses fixed md.
position ToastPosition "top" One of six display positions.
duration number 4000 Duration in ms; 0 persists.
onDismiss () => void — Dismissal callback.

Related functions:

  • dismissToast(id: string): void closes one Toast.

  • dismissAllToasts(position?: ToastPosition): void closes all Toasts or those at one position.

  • showToast(id: string, overrides?: ToastOptions): string | undefined triggers a registered <Toast template id="...">; overrides may change position, duration, and other runtime options.

<Toaster />

Keyword Type Default Description
offset number 16 Distance in px from viewport edge to Toast region.
maxVisible number 3 Visible depth per position, not a cap on queued toast() entries. New Toast pushes out the current last visible layer.
gap number 8 Visual offset between Toasts at one position, in px.
scaleStep number 0.05 Scale reduction per stack level; index 1 defaults to 0.95.
stackOpacityStep number 0.2 Opacity reduction per stack level; layers 2 and 3 default to 0.8 and 0.6.
stackMinOpacity number 0.6 Lower opacity bound for stacked entries.
stackDuration number 300 Stack transition duration in ms.
stackEasing string "ease" Stack transition easing.
width number | string — Toast region width. Defaults to content width; explicit width is capped on narrow viewports at calc(100vw - 2rem).

Motion behavior

Motion uses one Toast root:

  • Lifecycle whileAppear/whileDisappear controls root transform and --su-motion-opacity. Stack shifts and scale use independent CSS translate/scale, so they do not overwrite the lifecycle transform.

  • Stack opacity multiplies lifecycle fade. Layers two and three default to 0.8 and 0.6; exiting reduces the current opacity by 20%.

  • Extra offscreen exit distance merges into --snowui-toast-stack-translate-y alongside lifecycle percentage motion, so deep layers can leave the viewport.

  • Background, shadow, and backdrop-filter stay on the same root; there is no separate blur plate.

  • maxVisible limits visible layers, not queued entries. The old last layer enters pushed-out when a new Toast arrives.

  • Hovering any visible Toast at a position pauses the whole group’s dismissal timers. Only the front idle layer reveals the close X; deeper layers do not.

Motion parameters

Stage Frame motion Trigger state Top positions Bottom positions Duration Easing Description
Appear slideFromTop / slideFromBottom currentState="Appear" y: ["-100%", 0], opacity: [0.8, 1], scale: [0.96, 1] y: ["100%", 0], opacity: [0.8, 1], scale: [0.96, 1] 300ms ease The whole Toast starts slightly transparent and smaller; rich variant keeps its Background/3 glass surface.
Exit slideToTop / slideToBottom currentState="Disappear" y: [0, "-100%"], opacity: [1, 0.8], scale: [1, 0.96] y: [0, "100%"], opacity: [1, 0.8], scale: [1, 0.96] 300ms ease Reverse the entry combination with corresponding distance, speed, opacity, and size.
Exit beyond viewport Root element translate exiting / pushed-out Extra -(index * gap + offset + 20px). Extra index * gap + offset + 20px. 300ms ease Combine with lifecycle motion to move even deep Toasts at least 20px beyond the viewport edge.
Stack translation stackTranslate Stack index changes translateY(index * 8px) translateY(index * -8px) 300ms ease gap=8 by default; Toaster provides it. Exit adds offscreen distance.
Stack scale scale Stack index changes scale=max(0, 1 - index * scaleStep) Same as top. 300ms ease Default scaleStep=0.05; Toaster may override.
Stack opacity Frame fade Stack index changes max(stackMinOpacity, 1 - index * stackOpacityStep) Same as top. 300ms ease Multiplies lifecycle fade. Layers two/three default to 0.8/0.6; exit ends at 80% of current value.
Layer order Stack style Stack index changes z-index=maxVisible - index + 1 Same as top. — — Frontmost layer appears above the others.
Pushed-out last layer slide + fade + scale pushed-out Reverse motion along entrance direction, opacity: [1, 0.8], scale: [1, 0.96]. Reverse motion along entrance direction, opacity: [1, 0.8], scale: [1, 0.96]. 300ms ease After maxVisible, the old last layer plays a distinct push-out transition at the same speed as stacking.
Real content in back layers Stack style index > 0 Keep complete Toast content but disable pointer events. Same as top. Follows stack transition. ease Do not substitute empty background shells for deeper Toasts.
Hover pauses timers Timer Hover on visible layer Pause every visible Toast’s auto-dismiss timer at this position. Same as top. — — Hover on idle, stack-1, or any visible depth pauses the group; leaving resumes.

<Toast /> visual component

Inherits FrameProps except children, and adds:

Since v2.0.0, title, description, and icon Props are removed. Pass text through children; positive selects the generated icon, with no icon when omitted.


Global mount and command trigger

<script>    import { Button, Frame, Text, Toast, Toaster, showToast, toast } from "@snowui-design-system/components";</script> <Toaster /> <Button onclick={() => toast("Done")}>Show Toast</Button><Button onclick={() => toast({ text: "Something Wrong", positive: false })}>    Warning</Button><Button    onclick={() =>        toast({            text: "Saved",            positive: true,            variant: "rich",            position: "top-right",        })    }>    Rich Toast</Button>

Standalone Toast (without toast())

<Toast positive>Done</Toast><Toast positive={false}>Something Wrong</Toast><Toast>Plain Notice</Toast><Toast variant="rich" positive>    <Frame column class="flex-1 min-w-0">        <Text>Saved</Text>        <Text class="text-12 text-black-40">Your changes are synced.</Text>    </Frame></Toast>

Embedded as="toast" mode (v1.1.0)

An embedded Toast triggers on host click without an ID or manual showToast. See ComponentGuidelines §5 for floating components’ three activation modes (specs/maintainers/ComponentGuidelines.md).

<Toaster /> <Button variant="filled">    Save    <Toast as="toast" positive position="top-right">Saved</Toast></Button>

Template declaration and button trigger

<Toaster /> <Toast id="saved-rich-toast" template class="items-start" variant="rich" positive style="width: 15rem;">    <Frame column class="flex-1 min-w-0">        <Text>Text</Text>        <Text class="text-12 text-black-40">Text 2</Text>    </Frame>    <Button as="trailing" variant="gray">Button</Button></Toast> <Button onclick={() => showToast("saved-rich-toast", { position: "top-right" })}>    Add Rich Toast</Button>

Replacing generated icons

<Toast positive>    <Icon as="leading"><Heart /></Icon>    Added to favorites</Toast>

This area is maintained by the user; please obtain permission before AI modification.


Toast style overlay

Read the full LICENSE first; reuse that review for the same task, version, and scope.

First use public component Props to match the desired appearance, preserving the existing look where possible. If changes are necessary, follow the style selection and override order: use your own class (including Tailwind already in the project) or an instance style. The names below are public overrides actually consumed by source; check their scope and do not modify private DOM. Choose the correct SnowUI token family. External apps need not install SnowUI website utilities.

Variable Purpose and default reference
--snowui-button-opacity-override Opacity (see the component source code for the default value)
--snowui-icon-height-override Height (see the component source code for the default value)
--snowui-icon-width-override Width (see the component source code for the default value)
--snowui-toast-font-size-override Default variant font-size (default md=var(---text-14) / sm=var(--text-12))
--snowui-toast-gap-override Gap (default md=var(--gap-2)=8px / sm=var(--gap-1)=4px)
--snowui-toast-line-height-override Default variant line-height (default md=var(--leading-14) / sm=var(--leading-12))
--snowui-toast-padding-override Rich variant overall padding (default var(--padding-3) = 12px)
--snowui-toast-padding-x-override Default variant padding-x (default md=var(--padding-3)=12px / sm=var(--padding-2)=8px)
--snowui-toast-padding-y-override Default variant padding-y (default md=var(---padding-2)=8px / sm=var(--padding-1)=4px)
--snowui-toast-radius-override Border-radius (default var(--radius-4) = 16px)
--snowui-toast-success-color-override Built-in success icon color (default var(--secondary-green) = #71DD8C)
--snowui-toast-warning-color-override Built-in warning icon color (default var(--secondary-yellow) = #FFCC00)

Design Guide · Token · Combination Boundary

Toast type and status

Required Props: no named required Props.

Bindable Props: this component declares no named two-way binding; handle state updates through public callbacks or its host.

Inheritance: Omit<FrameProps, "children">. Consult the base class public documentation; fields excluded by Omit cannot be passed through unchanged.

Share Frame API · Return API

The following type declarations are actually referenced by public Props and come from source. A Svelte Snippet denotes a content fragment; ComponentProps denotes the Props of the corresponding component.

ComponentPartsOf

Source: components/src/logic/component-parts.svelte.ts

export type ComponentPartsOf<    T extends Record<string, Component<any>>,> = {    [K in keyof T]?: ConfigurableComponentPartProps<T[K]>;};

ConfigurableComponentPartProps

Source: components/src/logic/component-parts.svelte.ts

export type ConfigurableComponentPartProps<C extends Component<any>> = Partial<    Omit<ComponentProps<C>, ComponentPartControlledKey>>;

ComponentPartControlledKey

Source: components/src/logic/component-parts.svelte.ts

export type ComponentPartControlledKey =    | "children"    | "as"    | "value"    | "defaultValue"    | "open"    | "selected"    | "checked"    | "disabled"    | "readonly"    | "id"    | `on${string}`    | `aria-${string}`;

ToastVariant

Source: components/src/logic/toast.svelte.ts

export type ToastVariant = "default" | "rich";

ToastSize

Source: components/src/logic/toast.svelte.ts

export type ToastSize = "sm" | "md";

ToastPosition

Source: components/src/logic/toast.svelte.ts

export type ToastPosition =    | "top"    | "top-left"    | "top-right"    | "bottom"    | "bottom-left"    | "bottom-right";