Toast
A transient notification that announces itself and slips away — color and meaning on independent axes, in a live-region stack.
Live demo
Toast surfaces brief, transient feedback without stealing focus. Two axes drive it independently.
severity (success, warn, danger, info) carries the meaning: the status glyph and the live-region politeness, so danger/warn announce assertively. tone carries the color, from the full palette. A severity paints its standard color by default (danger reads red), but a tone overrides it, and a color-only toast (a non-status tone, no severity) shows no glyph and announces politely. A xoji-toast-region is a fixed live-region container with an imperative toast(opts) method that pushes cards; each carries one of two variants: soft, an overlay card with a colored edge, or solid, a fully filled card. Toasts enter and leave with a tokened transition, auto-dismiss after a configurable delay that pauses while the pointer or focus rests on them, and may carry a single action button and a close button. A standalone xoji-toast element is also exposed for declarative, statically-placed notices.
When to use
How this component composes with the rest of the set.
Props
10 props, straight from the manifest.
| Prop | Type | Default | Bindings | Description |
|---|---|---|---|---|
Appearance
Variants
soft
An overlay surface card with a tone-colored border and tone-colored icon.
solid
Filled with the tone color, with on-fill ink and icon.
States
enter
Mount transition: the toast fades and slides into place over --duration-base.
leave
Dismiss transition: the toast fades and slides out before removal.
action-hover
Pointer over the action button: overlay paints the hover tint.
focus-visible
Keyboard focus on the action or close button: a token ring plus a transparent outline promoted in forced-colors mode.
Anatomy
The named parts that make up the component, with their selectors.
toast-region
The fixed, non-focus-stealing live-region container that stacks and announces toasts.
toast
A single notification card carrying the variant and tone classes.
icon
The severity glyph, shown when a severity is set, drawn in the card color (soft) or the on-fill ink (solid). Project an icon slot to override it (declarative xoji-toast / Toast).
message
The notification text; the content that gets announced.
action
An optional inline action button that runs a callback then dismisses the toast.
close
The dismiss button in the top corner.
Tokens & coverage
What the component consumes, checked live against what the algorithm produces.
Live coverage check against the xoji-default register
(derive(xojiDefault, { anchors }) →
coverComponent(manifest, register)). Every token this component
consumes must be a key the algorithm produces.
--accent
--accent-2
--accent-2-fg
--accent-3
--accent-3-fg
--accent-4
--accent-4-fg
--accent-fg
--black
--black-fg
--blue
--blue-fg
--border-normal
--border-thick
--border-thin
--brown
--brown-fg
--cyan
--cyan-fg
--danger
--danger-fg
--duration-base
--duration-fast
--ease-emphasized
--ease-standard
--elevation-5
--fg-0
--font-sans
--gray
--gray-fg
--green
--green-fg
--info
--info-fg
--leading-normal
--leading-tight
--neutral
--neutral-fg
--orange
--orange-fg
--pink
--pink-fg
--purple
--purple-fg
--radius-md
--radius-sm
--red
--red-fg
--ring
--shadow
--space-0
--space-1
--space-3
--space-4
--space-5
--space-6
--state-hover
--state-press
--success
--success-fg
--surface-overlay
--surface-overlay-border
--text-body
--text-lg
--text-sm
--warn
--warn-fg
--weight-medium
--weight-semibold
--white
--white-fg
--yellow
--yellow-fg
Slots
The toast message (declarative xoji-toast / Toast).
Overrides the built-in severity glyph on a declarative toast; fill it to show your own icon (not available through the imperative toast(opts) API).
Accessibility
Code
Tones, variants, and the imperative region
Push toasts from a region, or place a standalone toast declaratively. The four status tones span both variants.
<xoji-toast-region id="toasts" placement="bottom-right"></xoji-toast-region>
<script type="module">
const region = document.getElementById("toasts");
region.toast({ message: "Settings saved." });
region.toast({
tone: "success",
variant: "solid",
message: "Your profile is live.",
});
region.toast({
tone: "danger",
message: "Upload failed.",
actionLabel: "Retry",
onAction: () => retryUpload(),
});
region.toast({
tone: "info",
message: "Sync paused while offline.",
duration: 0,
});
</script>
<script lang="ts">
import { Toast } from "@xoji/svelte";
</script>
<Toast tone="success" variant="soft">Settings saved.</Toast>
<Toast tone="danger" actionLabel="Retry" onaction={() => retryUpload()}>
Upload failed.
</Toast>
<Toast tone="info" closable={false}>Sync paused while offline.</Toast>
---
import { Toast } from "@xoji/astro";
---
<Toast tone="success" variant="soft">Settings saved.</Toast>
<Toast tone="danger" actionLabel="Retry">Upload failed.</Toast>
<Toast tone="info" closable={false}>Sync paused while offline.</Toast>