# Sileo Svelte complete documentation
---
title: Sileo Svelte
description: Animated toast notifications for Svelte 5.
label: Overview
---
Sileo Svelte displays compact notifications. When content needs more room, a toast expands in place. Loading, success, and error messages can update the same toast instead of replacing it.
This package is an unofficial Svelte port of [the original Sileo library](https://github.com/hiaaryan/sileo).
## Start here
Install with npm, pnpm, Bun, or Yarn.
```bash
npm install sileo-svelte
```
Mount one toaster near the root of your app.
```svelte
```
Call `sileo` from any client-side component.
```svelte
```
## Choose a flow
- [Creating toasts](/docs/creating-toasts): show, update, and dismiss notifications.
- [Async flows](/docs/async-flows): follow an upload or save from loading to completion.
- [Customization](/docs/customization): change colors, add frosted glass, or render Svelte snippets.
Working with a coding agent? Install the [Sileo Svelte skill](/docs/agent-skill) for the same API and styling guidance.
## Requirements
Sileo Svelte requires Svelte 5.56 or newer. Motion is included as a runtime dependency; the package has no utility CSS dependency. Import its stylesheet once, then use normal Svelte components and TypeScript.
## Try the real component
Use the [playground](/playground) to change the state, text, position, timing, and appearance. Show several toasts to test stacking, or update the last toast in place. The Code view gives you the matching Svelte component.
The Examples tab covers promises, retry actions, scoped defaults, and snippets.
---
---
title: Installation
description: Add the package, import its styles, and mount one toaster for the application.
label: Installation
---
## Install the package
Use the package manager already used by your project. Sileo Svelte requires Svelte 5.56 or newer. The Motion runtime is installed with the package.
```bash
npm install sileo-svelte
```
## Mount the toaster
Import the stylesheet once. In SvelteKit, the root layout is a good place for both imports.
```svelte
{@render children()}
```
`Toaster` also renders an optional `children` snippet. You can wrap the app instead if that fits your layout.
```svelte
{@render children()}
```
Mount one toaster. Multiple instances share the store and render duplicate notifications.
## Set application defaults
The `options` prop applies defaults to every toast. Individual calls can override them.
```svelte
```
`offset` accepts one number, one CSS length, or an object with `top`, `right`, `bottom`, and `left` values.
## Server rendering
Mount the component in a normal Svelte layout. Call `sileo` in browser interactions such as button handlers, form results, or client-side tasks. Server-side notification calls do not enqueue toasts or transfer messages to the browser.
## Confirm the setup
Add a temporary button and click it in the browser.
```svelte
```
If nothing appears, check that the stylesheet import reaches the browser and that the toaster is mounted once.
---
---
title: Agent skill
description: Give a coding agent the Sileo API contracts it needs before it changes your app.
label: Agent skill
---
The `sileo-svelte` skill covers setup, toast updates, promise results, styling, snippets, and accessibility. It directs agents to the installed package declarations and the relevant documentation before they choose an API.
## Install
Install from the Sileo repository with the [skills CLI](https://skills.sh/docs):
```bash
npx skills add mielsense/sileo-svelte --skill sileo-svelte
```
You can [read the skill](/skill.md) before installing it. The repository and this site serve the same source file.
## Version compatibility
The skill follows the 0.2 API, including explicit IDs, removing actions with `button: null`, and frosted glass backgrounds. Check the [changelog](/docs/changelog) and your installed version before using these options.
The skill ships in the npm package under `skills/sileo-svelte` as well as in this repository. The site serves that same file, so its instructions stay together with the library changes.
## Use it
Name the skill and describe what should happen in your application.
```text
Use $sileo-svelte to show loading, success, and error notifications when settings save.
Keep the existing error handling and mount Toaster once in the root layout.
```
For styling work, give the agent the context it needs to check readability:
```text
Use $sileo-svelte to make a frosted glass toast that works over the images on this page.
Check keyboard interaction, narrow screens, and the appearance without backdrop blur.
```
## Read without installing
Agents can fetch the [skill discovery index](/.well-known/agent-skills/index.json) or [SKILL.md](/.well-known/agent-skills/sileo-svelte/SKILL.md) directly. The skill is self-contained and links to detailed documentation when needed.
The [documentation index](/llms.txt) lists every guide as Markdown. The [full documentation](/llms-full.txt) combines them into one file.
---
---
title: Changelog
description: Release history, compatibility notes, breaking changes, fixes, and upgrade guidance.
label: Changelog
---
This project is still in beta. Each release is marked as breaking or non-breaking so upgrades do not depend on version numbers alone.
## 0.2.1 · 2026-09-08
**Release impact: Non-breaking**
### Fixed
- Frosted glass backgrounds now follow the body throughout expansion and collapse, including in WebKit.
- The documentation center column has more room for text and code, matching the landing page and playground width on wide screens.
## 0.2.0 · 2026-09-08
**Release impact: Breaking**
### Breaking changes
- The minimum supported Svelte version is now 5.56. Update Svelte before upgrading.
### Added
- Frosted glass backgrounds with `styles.backdropFilter` and a translucent `fill`.
- `classes.toast` and `classes.background` for styling the outer toast and its background.
- Explicit toast IDs in the typed creation API and `button: null` to remove an action during an update.
- A configurable playground with real stacking, expiry, updates, and matching example code.
- A repository-owned agent skill covering the public 0.2 API, application defaults, promises, snippets, styling, and accessibility. It ships in the npm package and has its own docs page and HTTP discovery endpoints.
- Installation blocks with npm, pnpm, Bun, and Yarn choices that remember the selected package manager.
- Icon tooltips for pointer and keyboard users, with reduced-motion support.
### Changed
- Toast motion now runs through the framework-independent `motion` package. CSS is responsible only for layout and appearance.
- Interrupted shape animations now retarget from their rendered geometry, and all active controls are released when a toast unmounts.
- Header states crossfade with a short blur and positional overlap instead of flashing between text values.
- Swipe gestures use progressive resistance, velocity-aware dismissal, and a spring return.
- Geometry calculations now live in a small typed module instead of being mixed into rendering and gesture code.
- `--sileo-duration` controls visual timing and lifecycle completion instead of competing with fixed removal timers.
- Reworked the docs, homepage, and playground around shared navigation styles and a bordered layout. Preview and code share one toolbar with copy and clear actions.
- Added a fixed site footer for GitHub, theme, and `llms.txt` links; moved page navigation to the header's right edge.
- Added subtle disclosure, tooltip, copy-feedback, and navigation animations that respect reduced motion.
- Tagged releases now run CI, test the npm tarball in a separate consumer, and publish that same artifact with provenance.
### Fixed
- Dismissing a toast during a pending close no longer leaves it in the store.
- A completed promise no longer revives a closing or dismissed toast.
- Promise notifications preserve scoped position defaults.
- Server-side notification calls no longer retain toast data across requests.
- Keyboard focus pauses expiry and automatic collapse while an action is in use.
- New swipe gestures stop an unfinished return animation.
- An explicit update can interrupt exit without an old completion removing the updated toast.
- Closing during a pending content update completes the close.
- Collapsed content stays measurable without forcing layout inside a skipped subtree.
- Updated dependencies with reported security advisories.
- Raw Markdown links now bypass client-side routing, preventing false 404 pages.
- Centered the error page and matched its recovery button sizes.
- Reduced-motion preferences now skip transform-heavy entrances, shape motion, header blur, and loader rotation.
- Playground examples no longer leak notifications into the documentation route.
- Toast geometry stays aligned after runtime width and height changes.
- Promise completions cannot overwrite a newer toast that reused the same id.
- Old close and dismiss timers cannot remove a newer toast that reused the same id.
- A stable live region now announces the first toast as well as later updates.
- Interactive description snippets receive keyboard focus without triggering swipe capture.
- Updates to older toasts announce their result even when a newer toast remains on screen.
- Extra touch pointers no longer interrupt an active swipe.
### Upgrade
Update Svelte to 5.56 or newer with your project's package manager, then install the library:
```bash
npm install sileo-svelte@^0.2.0
```
`SileoPromiseOptions` now permits an `action` result without a redundant `success` mapping. Existing calls remain valid.
## 0.1.1 · 2026-05-20
**Release impact: Non-breaking**
- Corrected default lifetimes for loading, action, and promise-driven toasts.
- Raised the viewport stacking level so notifications remain above application chrome.
- Rendered toast actions with semantic buttons.
## 0.0.5 · 2026-02-18
**Release impact: Breaking**
- Renamed public props and updated examples to match the new API.
- Added CSS custom properties and custom class support.
- Improved the demo's dark theme.
## 0.0.2 · 2026-02-18
**Release impact: Initial beta release**
- Published the first npm beta with state helpers, toast updates, styling hooks, and starter documentation.
---
---
title: Creating toasts
description: Choose a state, update an existing notification, and control its lifetime.
label: Creating toasts
---
## State helpers
Each state helper returns the toast id.
```ts
import { sileo } from 'sileo-svelte';
const id = sileo.success({
title: 'Release saved',
description: 'Draft v2.4 is ready for review.'
});
```
Available helpers are `show`, `success`, `error`, `warning`, `info`, `action`, and `loading`.
```ts
sileo.error('Could not save the release');
sileo.warning('The token expires tomorrow');
sileo.info('A new build is available');
```
A string becomes the title. Pass an object when you need a description, position, duration, action, or visual override.
## Replace a named toast
Pass `id` when several calls refer to the same notification. Reusing it replaces the previous toast instead of adding another.
```ts
sileo.loading({ id: 'upload', title: 'Uploading report.pdf' });
sileo.success({ id: 'upload', title: 'Report uploaded' });
```
Replacement starts a fresh lifetime and uses the new call's options. Use `update` when you want to keep options you do not change.
## Update one toast
Keep the id returned by the first call, then update that toast in place.
```ts
const id = sileo.loading({
title: 'Publishing release',
duration: null
});
await publishRelease();
sileo.update(id, {
state: 'success',
title: 'Release published',
description: 'Traffic is moving to v2.4.'
});
```
Use this for one task with several states. Creating a new toast for every state makes the interface jump and leaves stale messages behind.
Updates preserve omitted fields. Set `button: null` to remove an existing action after the task finishes.
```ts
sileo.update(id, {
state: 'success',
title: 'Payment complete',
button: null
});
```
## Dismiss, close, and clear
```ts
sileo.dismiss(id);
sileo.close(id);
sileo.clear();
sileo.clear('bottom-right');
```
`dismiss` starts the exit animation. `close` collapses the toast before exiting. `clear` removes notifications immediately, either everywhere or at one position.
## Control duration
Pass a duration in milliseconds. Use `null` for a notification that must remain until code closes it or the person acts.
```ts
sileo.action({
title: 'Payment needs attention',
duration: null,
button: {
title: 'Retry',
onClick: (id) => retryPayment(id)
}
});
```
Action and loading toasts stay open by default. Other states last 6000ms. Hover on a fine pointer or keyboard focus inside a toast pauses expiry. Leaving the toast restarts its full duration.
## Reuse defaults
Create a scoped API when several notifications share settings.
```ts
const billing = sileo.with({
duration: 4000,
position: 'bottom-right'
});
billing.info({
title: 'Invoice ready',
description: 'Invoice 4921 can be downloaded.'
});
```
---
---
title: Async flows
description: Track promises with one notification that moves through loading, success, and error states.
label: Async flows
---
## Track a promise
Pass an existing promise or a function that returns one.
```ts
const result = await sileo.promise(uploadBuild(), {
loading: { title: 'Uploading build' },
success: (build) => ({
title: 'Build uploaded',
description: `${build.files} artifacts are ready.`
}),
error: (error) => ({
title: 'Upload failed',
description: error instanceof Error ? error.message : 'Try again.'
})
});
```
The returned promise preserves the original result type. A rejected promise still rejects, so handle errors in your calling code. If the toast was closed, dismissed, cleared, or replaced, the result does not bring it back.
## Reuse a loading toast
Pass an id when code already created the loading state.
```ts
const id = sileo.loading({
title: 'Uploading build',
position: 'bottom-left'
});
await sileo.promise(() => uploadBuild(), {
id,
loading: { title: 'Uploading build' },
success: { title: 'Build uploaded' },
error: { title: 'Upload failed' }
});
```
This keeps the same toast and position throughout the task.
## Add a follow-up action
The optional `action` mapping replaces the success state. Use it when the completed task has one useful next step instead of a passive confirmation.
```ts
await sileo.promise(() => createReport(), {
loading: { title: 'Building report' },
error: { title: 'Report failed' },
action: (report) => ({
title: 'Report ready',
button: {
title: 'Open report',
onClick: () => openReport(report.id)
}
})
});
```
## Handle retries
Update the same id when an action starts another request.
```ts
function retryPayment(id: string) {
sileo.update(id, {
state: 'loading',
title: 'Retrying payment'
});
retry().then(
() => sileo.update(id, { state: 'success', title: 'Payment captured' }),
() => sileo.update(id, { state: 'error', title: 'Payment declined again' })
);
}
```
---
---
title: Customization
description: Change placement, timing, color, classes, and rich content without replacing the package CSS.
label: Customization
---
## Position
Set a default on `Toaster`, then override it on individual calls when needed.
```svelte
```
```ts
sileo.info({
title: 'Download started',
position: 'bottom-center'
});
```
Supported positions are `top-left`, `top-center`, `top-right`, `bottom-left`, `bottom-center`, and `bottom-right`.
## Color and shape
Use `fill` for the toast background and `roundness` to change the corners.
```ts
sileo.action({
title: 'Custom surface',
fill: '#1f1f1f',
roundness: 8,
button: {
title: 'Close',
onClick: (id) => sileo.close(id)
}
});
```
Keep enough contrast between the fill, text, badge, and button colors. Test both collapsed and expanded states.
## Frosted glass
Use a translucent `fill` with `styles.backdropFilter`. Sileo blurs the page behind the toast and clips the result to its animated shape. The title, icon, and description stay sharp.
```ts
sileo.success({
title: 'Saved',
description: 'Your changes are ready.',
fill: 'rgba(24, 24, 27, 0.55)',
styles: {
backdropFilter: 'blur(16px) saturate(1.4)',
titleColor: '#ffffff',
descriptionColor: '#f4f4f5'
}
});
```
An opaque fill hides the blur. A flat background also gives the filter little to blur. Test your toast over the images, text, and colors in your app, then check that the text remains readable.
The browser must support CSS `backdrop-filter` and SVG masks. Without backdrop filtering, the translucent fill still appears. Ancestors with `filter`, masks, or opacity below `1` can limit which content the browser blurs. Mount `Toaster` near the application root, outside those containers.
## Styling the whole toast
`classes.toast` targets the outer toast. `classes.background` targets the SVG background, or the masked HTML background when `backdropFilter` is set. Import your styles after `sileo-svelte/styles.css`.
```ts
sileo.info({
title: 'New comment',
classes: { toast: 'comment-toast' }
});
```
```css
/* Use global CSS. Toaster renders outside the component that calls sileo. */
.comment-toast {
--sileo-width: 400px;
--sileo-title-color: #e0e7ff;
--sileo-description-color: #f5f3ff;
}
```
Sileo animates the toast's height, opacity, and transform. Keep those properties available to the animation. Set width with `--sileo-width` so measurements and the background stay aligned.
## Motion timing
Set `--sileo-duration` to change the toast's visual motion. The default is `600ms`.
```css
:root {
--sileo-duration: 500ms;
}
```
Sileo reads this value when a toast mounts and uses it for its Motion spring and state transitions. People who prefer reduced motion get immediate layout and opacity changes with no transform-heavy entrance or loader motion.
## Typed style slots
The `styles` object changes supported visual values on one toast.
```ts
sileo.success({
title: 'Theme updated',
styles: {
titleColor: '#ffffff',
descriptionColor: '#d4d4d4',
buttonColor: '#000000',
buttonBackground: '#ffffff'
}
});
```
Use `classes` when the application already has a class-based styling system.
```ts
sileo.info({
title: 'New comment',
classes: {
title: 'notification-title',
description: 'notification-description',
button: 'notification-action'
}
});
```
## Rich descriptions and icons
Sileo accepts Svelte snippets for `description` and `icon`.
```svelte
{#snippet releaseDetails()}
Release v2.4Six regions are healthy.
{/snippet}
{#snippet releaseIcon()}
R
{/snippet}
```
Use `button` for a single action. Description snippets can also contain links, buttons, and inputs. The toast header enters the tab order when a description is a snippet. Focus opens the content and pauses expiry. Escape returns focus to the header and collapses the toast.
---
---
title: API reference
description: Methods exposed by sileo and the option types accepted by every toast.
label: API reference
---
## State methods
```ts
sileo.show(input, description?)
sileo.success(input, description?)
sileo.error(input, description?)
sileo.warning(input, description?)
sileo.info(input, description?)
sileo.action(input, description?)
sileo.loading(input, description?)
```
Each method accepts a title string or a `SileoOptions` object and returns the toast id. Pass `id` to replace an existing notification with that name.
## Lifecycle methods
```ts
sileo.update(id, options)
sileo.dismiss(id)
sileo.close(id)
sileo.clear(position?)
```
`update` accepts `SileoOptions` fields plus an optional `state`. Its first argument identifies the toast; an `id` inside the options does not rename it. Omitted fields stay unchanged. Set `button: null` to remove an action. `clear` can target one of the six positions.
## Promise
```ts
sileo.promise(
promise: Promise | (() => Promise),
options: SileoPromiseOptions
): Promise
```
```ts
type PromiseResult = SileoOptions | ((data: T) => SileoOptions);
type SileoPromiseOptions = {
id?: string;
loading: Pick;
error: SileoOptions | ((error: unknown) => SileoOptions);
position?: SileoPosition;
} & ({ success: PromiseResult; action?: undefined } | { action: PromiseResult; success?: PromiseResult });
```
Provide either `success` or `action`. If both are present, `action` becomes the final state.
## Scoped defaults
```ts
const scoped = sileo.with(defaults);
```
The returned object has the same state, promise, update, dismiss, close, and clear methods. Call-level options override scoped defaults.
## SileoOptions
| Field | Type | Purpose |
| ------------- | --------------------- | ----------------------------------------------- |
| `id` | `string` | Stable identifier for replacing a toast. |
| `title` | `string` | Primary notification text. |
| `description` | `string \| Snippet` | Supporting text or structured Svelte content. |
| `position` | `SileoPosition` | Viewport placement for this toast. |
| `duration` | `number \| null` | Lifetime in milliseconds. `null` keeps it open. |
| `icon` | `Snippet \| null` | Custom icon content or no icon. |
| `button` | `SileoButton \| null` | One labeled action, or `null` to remove it. |
| `fill` | `string` | Toast background color. |
| `roundness` | `number` | Corner roundness used by the toast shape. |
| `autopilot` | `boolean \| object` | Automatic expand and collapse timing. |
| `classes` | `SileoClasses` | Class names for supported internal parts. |
| `styles` | `SileoStyles` | Typed colors and backdrop filtering. |
## Exported types
```ts
import type {
SileoApi,
SileoButton,
SileoClasses,
SileoInput,
SileoOptions,
SileoPosition,
SileoPromiseOptions,
SileoScopedApi,
SileoState,
SileoStyles
} from 'sileo-svelte';
```
## Background styling
Set `styles.backdropFilter` to a CSS backdrop filter such as `blur(16px) saturate(1.4)`. Combine it with a translucent `fill` to blur the content behind the animated shape. See [frosted glass](/docs/customization#frosted-glass) for an example and browser limitations.
`classes.toast` applies to the outer toast. `classes.background` applies to the SVG background, or the masked HTML background when a backdrop filter is active. These are global class names, like the existing title and description classes.
---
---
title: Toaster reference
description: Configure the mounted toaster, viewport offsets, and application-wide defaults.
label: Toaster
---
## Props
```ts
interface ToasterProps {
children?: Snippet;
position?: SileoPosition;
offset?:
| number
| string
| {
top?: number | string;
right?: number | string;
bottom?: number | string;
left?: number | string;
};
options?: Partial;
}
```
## position
The default is `top-right`. A position passed to an individual toast overrides it.
```svelte
```
## offset
A number becomes pixels. A string can use any CSS length. One value applies to all viewport edges.
```svelte
```
Pass an object when each edge needs a different value.
```svelte
```
Only the edges used by a toast position affect that viewport.
## options
Use `options` for application defaults.
```svelte
```
Precedence runs from application defaults to scoped defaults to options passed to the toast call.
## children
`children` is optional. When supplied, the toaster renders it before the notification viewports.
```svelte
{@render children()}
```
This form is useful when the toaster should wrap the route tree. Mount it once either way.