--- name: sileo-react-toasts description: Provide implementation guidance for Sileo (npm package "sileo") toast notifications in React apps. Use when adding the Toaster viewport, firing global toasts via sileo.success/error/warning/info/show/action, handling async flows with sileo.promise, dismissing/clearing toasts, configuring positions/offset, theming with light/dark/system modes, and customizing styling via fill, styles overrides, autopilot, roundness, CSS variables, and data-attribute selectors. Also use this skill for swipe-to-dismiss behavior, custom icons, JSX descriptions, reduced-motion support, TypeScript type exports, and understanding Sileo's internal SVG gooey morphing architecture. Make sure to use this skill whenever the user mentions sileo, toast notifications in React, gooey toasts, physics-based notifications, or wants to add any kind of toast/notification system using sileo, even if they don't explicitly name the package. keywords: [sileo, react, toast, toasts, notifications, toaster, ui, promise, action, styling, tailwind, css-variables, theme, dark-mode, swipe, gooey, spring-physics] --- # SKILL: Sileo (React Toast Notifications) > **Official documentation:** https://sileo.aaryan.design/docs > **API Reference:** https://sileo.aaryan.design/docs/api > **Toaster API:** https://sileo.aaryan.design/docs/api/toaster > **Styling Guide:** https://sileo.aaryan.design/docs/styling > **Playground:** https://sileo.aaryan.design/play > **GitHub:** https://github.com/hiaaryan/sileo --- ## What is Sileo? **Sileo** is a tiny, opinionated, **physics-based** toast component for React. It uses **gooey SVG morphing** (via an `feGaussianBlur` + `feColorMatrix` filter chain) and **spring animations** (powered by `motion/react`, formerly Framer Motion) to create buttery-smooth notifications that look beautiful by default with zero configuration. Sileo is **not** a general-purpose notification center. It is a highly polished, visually distinctive toast system designed for single-line feedback messages with optional expandable descriptions. **Key characteristics:** - Framework: **React only** (ships with `"use client"` directive for Next.js App Router compatibility) - Peer dependency: **`motion`** (spring physics engine, `motion/react`) - Architecture: SVG-based rendering with gooey blob morphing between pill (collapsed) and card (expanded) states - TypeScript-first: All types are exported (`SileoOptions`, `SileoPosition`, `SileoState`, `SileoStyles`, `SileoButton`) - Accessibility: Uses `aria-live="polite"` on viewport sections, respects `prefers-reduced-motion` - Swipe-to-dismiss: Built-in pointer-event-based vertical swipe gesture (30px threshold) --- ## Installation ```bash npm install sileo ``` Sileo requires `react` and `motion` as peer dependencies. --- ## Quick Setup 1. Mount `` **once** at your app's root layout. 2. Fire toasts from anywhere by importing `sileo`. ```tsx import { sileo, Toaster } from "sileo"; export default function App() { return ( <> ); } ``` > Because `sileo` ships with `"use client"`, it works seamlessly in Next.js App Router without extra wrappers. --- ## Basic Usage Sileo exposes a global controller `sileo` with state-specific shortcuts: ```tsx import { sileo } from "sileo"; // State shortcuts (each returns the toast `id` as a string) sileo.success({ title: "Saved", description: "Your changes were stored." }); sileo.error({ title: "Failed", description: "Could not save." }); sileo.warning({ title: "Warning", description: "Disk space low." }); sileo.info({ title: "Tip", description: "Try the new feature." }); // Generic toast (defaults to success, but accepts `type` for dynamic state) sileo.show({ title: "Done", type: "success" }); // Dynamic state selection sileo.show({ type: response.ok ? "success" : "error", title: "Upload complete", }); ``` --- ## All `sileo` Methods | Method | Returns | Description | | --- | --- | --- | | `sileo.success(options)` | `string` (id) | Green success toast | | `sileo.error(options)` | `string` (id) | Red error toast | | `sileo.warning(options)` | `string` (id) | Amber warning toast | | `sileo.info(options)` | `string` (id) | Blue info toast | | `sileo.action(options)` | `string` (id) | Toast with an action button | | `sileo.show(options)` | `string` (id) | Generic toast. Uses `options.type` for state, defaults to `"success"` | | `sileo.promise(promise, opts)` | `Promise` | Loading -> success/error flow. Returns the **original promise** | | `sileo.dismiss(id)` | `void` | Dismiss a specific toast by id | | `sileo.clear(position?)` | `void` | Clear all toasts, or only those at a specific position | --- ## `SileoOptions` Passed to every `sileo.*()` call. | Prop | Type | Default | Description | | --- | --- | --- | --- | | `title` | `string` | -- | Toast heading (displayed in the pill) | | `description` | `ReactNode \| string` | -- | Body content (shown when expanded). Accepts JSX for rich content | | `type` | `SileoState` | -- | Dynamic state for `sileo.show()`. One of `"success" \| "loading" \| "error" \| "warning" \| "info" \| "action"` | | `position` | `SileoPosition` | Toaster default | Override position for this individual toast | | `duration` | `number \| null` | `6000` | Auto-dismiss in milliseconds. `null` = sticky (never auto-dismisses) | | `icon` | `ReactNode \| null` | State icon | Custom icon replacing the default in the badge circle | | `fill` | `string` | `"#FFFFFF"` | SVG fill color for the toast background shape | | `styles` | `SileoStyles` | -- | CSS class overrides for sub-elements | | `roundness` | `number` | `16` | Border radius in pixels for the SVG shapes | | `autopilot` | `boolean \| { expand?: number; collapse?: number }` | `true` | Auto expand/collapse timing. `false` = hover only | | `button` | `SileoButton` | -- | Action button configuration | --- ## Action Toast Action toasts include a clickable button inside the expanded area: ```tsx sileo.action({ title: "New version available", description: "Reload to update", button: { title: "Reload", onClick: () => window.location.reload(), }, }); ``` ### `SileoButton` ```ts interface SileoButton { title: string; onClick: () => void; } ``` --- ## Promise Toast `sileo.promise` chains loading -> success/error states from a single promise. It returns the **original promise** so you can chain further. - The first argument can be a `Promise` **or a function** `() => Promise` (useful for lazy execution). - `success` and `error` can be static options or callbacks that receive the resolved/rejected value. - The optional `action` field, when provided, replaces the success toast with an action-state toast. ```tsx type User = { name: string }; const result = await sileo.promise(createUser(data), { loading: { title: "Creating account..." }, success: (user) => ({ title: `Welcome, ${user.name}!`, }), error: (err: any) => ({ title: "Signup failed", description: err?.message ?? "Unknown error", }), }); // `result` is the resolved User object ``` **With lazy promise (function):** ```tsx sileo.promise(() => fetch("/api/data").then((r) => r.json()), { loading: { title: "Fetching data..." }, success: { title: "Data loaded" }, error: { title: "Failed to load" }, }); ``` **With action replacing success:** ```tsx sileo.promise<{ url: string }>(uploadFile(file), { loading: { title: "Uploading..." }, success: { title: "Uploaded" }, // Ignored when `action` is present error: { title: "Upload failed" }, action: (data) => ({ title: "File ready", description: "Click to open", button: { title: "Open", onClick: () => window.open(data.url), }, }), }); ``` ### `SileoPromiseOptions` ```ts interface SileoPromiseOptions { loading: SileoOptions; success: SileoOptions | ((data: T) => SileoOptions); error: SileoOptions | ((err: unknown) => SileoOptions); action?: SileoOptions | ((data: T) => SileoOptions); position?: SileoPosition; } ``` --- ## Positions Six positions available. Set a default on ``, or override per toast: ```ts type SileoPosition = | "top-left" | "top-center" | "top-right" // default | "bottom-left" | "bottom-center" | "bottom-right"; ``` ```tsx // Override for a specific toast sileo.success({ title: "Saved", position: "top-left" }); ``` The `SILEO_POSITIONS` constant array is also exported for iteration: ```ts import { SILEO_POSITIONS } from "sileo"; // Not exported from index (internal) ``` --- # Toaster (Viewport Component) `` is the viewport component that renders toasts. Add it **once** at your root layout. ```tsx import { Toaster } from "sileo"; ``` ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `children` | `ReactNode` | -- | App content to render alongside toasts | | `position` | `SileoPosition` | `"top-right"` | Default position for all toasts | | `offset` | `number \| string \| { top?, right?, bottom?, left? }` | -- | Distance from viewport edges | | `options` | `Partial` | -- | Default options merged into every toast | | `theme` | `"light" \| "dark" \| "system"` | -- | Automatic fill based on color scheme. `"system"` follows OS preference | ## Theme The `theme` prop automatically sets the toast `fill` color based on the selected scheme, saving you from manually configuring dark/light fills: - `"light"` -> fill is `#1a1a1a` (dark toast on light backgrounds) + light description text - `"dark"` -> fill is `#f2f2f2` (light toast on dark backgrounds) + dark description text - `"system"` -> Follows `prefers-color-scheme` media query, reactively updates on OS change ```tsx ``` When `theme` is set, the viewport renders `data-theme="light"` or `data-theme="dark"` which CSS uses to auto-style description text opacity. > If you set both `theme` and `fill` on individual toasts, the per-toast `fill` takes precedence. ## Offset Accepts a number (px), a CSS string, or a per-side object: ```tsx ``` ## Default Options (global) ```tsx ``` Every toast will inherit these defaults. Per-toast options override them. The `styles` object is shallow-merged (per-toast styles overlay global styles). --- # Styling Sileo looks great out of the box. When customization is needed, there are several escape hatches. ## Fill Color `fill` sets the SVG background color of the toast shape. Default: `"#FFFFFF"`. For dark toasts, use a dark `fill` and pair it with light text via `styles`: ```tsx sileo.success({ title: "Dark toast", fill: "#171717", styles: { title: "text-white!", description: "text-white/75!", }, }); ``` ## Style Overrides (`styles`) Override CSS classes on individual sub-elements. When using Tailwind, add `!` for specificity. ### `SileoStyles` ```ts interface SileoStyles { title?: string; // The heading text description?: string; // The body/description area badge?: string; // The icon badge circle button?: string; // The action button } ``` ### Available Data-Attribute Selectors | Key | Element | CSS Selector | | --- | --- | --- | | `title` | Heading text | `[data-sileo-title]` | | `description` | Body/description area | `[data-sileo-description]` | | `badge` | Icon badge circle | `[data-sileo-badge]` | | `button` | Action button | `[data-sileo-button]` | Additional data-attributes available for CSS targeting: | Selector | Description | | --- | --- | | `[data-sileo-toast]` | The outermost toast element (a `