惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
J
Java Code Geeks
P
Proofpoint News Feed
Recent Announcements
Recent Announcements
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园_首页
Hugging Face - Blog
Hugging Face - Blog
MongoDB | Blog
MongoDB | Blog
人人都是产品经理
人人都是产品经理
博客园 - 【当耐特】
雷峰网
雷峰网
D
DataBreaches.Net
B
Blog RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 聂微东
V
Visual Studio Blog
Apple Machine Learning Research
Apple Machine Learning Research
N
Netflix TechBlog - Medium
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Martin Fowler
Martin Fowler
有赞技术团队
有赞技术团队
Blog — PlanetScale
Blog — PlanetScale
Engineering at Meta
Engineering at Meta

Echo JS

billboard.js 4.1.0: Live resizing, configurable subchart, React subpath & CSP-safe worker From 1,256ms to 96ms: Fixing INP in a Massive React Dropdown GitHub - evoluteur/cymatics: Play a frequency and watch the sand settle into its Chladni figure, computed from the wave equation. Memdeklaro - The Basics of Decentralized Identity (DID) and Self-Sovereign Identity (SSI) How Railmid Works GitHub - evoluteur/platonic-solids: Turn the five Platonic solids in 3D, show their duals, read their measurements, and print the nets to fold your own. Sharing Application State in a URL GitHub - evoluteur/sacred-geometry: Sacred Geometry Generator: draw, tune, and export Vesica Piscis, Seed of Life, Flower of Life, Metatron's Cube, and the Golden Spiral as SVG Best of Self-Sovereign Identity: Digitalcourage, World Passport and Memdeklaro Reads Are Subscriptions - Migrating from Zustand to Coaction GitHub - evoluteur/binaural-beats: Simple web page to play binaural beats for sleep, meditation, relaxation, and focus: Delta, Theta, Alpha, Beta, and Gamma brainwave frequencies, with an optional pink or brown noise bed. Building a High-Performance Data Grid in React, Vue, and Svelte I built a flight recorder for AI sessions React Authentication With JWT, Zustand, and Axios | JavaScript Tools Blog My idempotency library had one job. A dropped connection made it run the payment twice. "half-open" twice is not the same state: the bug that shaped breakwater 1.0 GitHub - evoluteur/evolutility-server-node: Framework for building REST APIs for CRUD with models rather than code (using Node.js, Express, and PostgreSQL). React Router v8 in Action: Lazy Loading and Nested Routes One $ for every environment | Xec My test suite had 100% coverage. Mutation testing still found real bugs. The type-safe data layer for Kysely | Kysera What JavaScript Obfuscation in the AI Era | JavaScript Tools Blog Using Mongoose Studio with Apache Cassandra via Data API GitHub - trekhleb/yesbrainer: 🧠 A council of AI models for the decisions that aren't no-brainers — they answer in parallel, debate to consensus, or get judged to a verdict. Browser-only, open source, bring your own keys (BYOK), no backend. Node.js has plenty of circuit breakers. So why did I build another one? My Redis library said the write succeeded. Redis was down. GitHub - Techthos/gadget: Prebuilt, interactive HTML widgets for MCP Apps in Go — data tables and forms, self-contained in a single binary, host-themed, spec-compliant. GitHub - evoluteur/react-morph-charts: React component for bubble chart, bar chart, and pie chart, with animated morphing transitions between charts, on hover, and on window resize. Interactive Metaballs Tutorial
toast-queue — Accessible, customizable toast notifications
André Ruffert · 2026-08-25 · via Echo JS

Documentation

Using toast-queue

Add accessible toast notifications to any modern web app with a small, framework-agnostic API. Start with the quick example, then customize the queue and presentation to match your application.

Install

Install toast-queue from npm:

npm install toast-queue Copy code

Quick start

Create a queue and add a toast.

import { ToastQueue } from 'toast-queue'; const toastQueue = new ToastQueue(); toastQueue.add('Your changes have been saved.'); Copy code

That's it. toast-queue handles the queue lifecycle, positioning, dismissal, interaction states, and screen-reader announcements for you.

Adding toasts

For simple messages, pass a string to .add(). For richer notifications, pass an object containing a title and description.

Simple message

toastQueue.add('Your profile has been updated.'); Copy code

Rich notification

toastQueue.add({ title: 'Changes saved', description: 'Your profile has been updated.', }); Copy code

With an action

toastQueue.add( { title: 'Update available', description: 'A new version is ready to install.', }, { action: { label: 'Reload', onClick: () => location.reload() }, } ); Copy code

Controlling the queue

Configure the queue when you create it. You can control where toasts appear, how long they remain visible, and how many are considered visible at once.

const toastQueue = new ToastQueue({ position: 'bottom-end', duration: 6000, visibleLimit: 3, }); Copy code

Position

Choose from six logical positions: top-start, top-center, top-end, bottom-start, bottom-center, and bottom-end. You can also change the position after creating the queue.

const toastQueue = new ToastQueue({ position: 'top-end', }); Copy code

Visible limit

visibleLimit controls how many toasts are considered visible at the same time. Additional toasts remain rendered in the queue and are marked hidden [data-hidden] until the visible limit allows them to be shown.

const toastQueue = new ToastQueue({ visibleLimit: 3, }); Copy code

Per-toast options

Individual toasts can customize their behavior by passing options as the second argument to .add().

toastQueue.add('Your changes have been saved.', { duration: 6000, dismissible: true, priority: 'normal', className: 'my-toast', onClose: () => { console.log('Toast closed'); } }); Copy code

Disable automatic dismissal

Set duration to 0 when a toast should remain visible until it is dismissed by the user or your application.

toastQueue.add( { title: 'Import finished', description: 'Your files are ready.', }, { duration: 0, } ); Copy code

Styling

toast-queue provides the queue behavior, accessibility primitives, interaction states, and sensible structural styles. It does not impose a visual design system.

Customize the component with the data-part attributes exposed by the toast markup. Styling hooks and CSS custom properties are also available for queue-level positioning and interaction effects.

toast-queue { /* ... */ &[data-active] { /* ... */ } &[data-position] { /* ... */ } [data-part="group"] { /* ... */ } [data-part="item"] { /* ... */ } [data-part="item"][data-hidden] { /* ... */ } [data-part="item"][data-peek] { /* ... */ } [data-part="toast"] { /* ... */ } [data-part="icon"] { /* ... */ } [data-part="actions"] { /* ... */ } [data-part="action-button"] { /* ... */ } [data-part="close-button"] { /* ... */ } } Copy code

Positioning

Use logical offset variables to control the distance from the viewport.

toast-queue { --tq-offset: 1rem; /* Or control each axis independently. */ --tq-offset-inline: 1.5rem; --tq-offset-block: 2rem; } Copy code

Presets

Optional CSS presets provide ready-made layouts without taking control away from your application.

  • list— a conventional vertical queue where each toast occupies its own space.
  • stacked— a compact card stack where hidden toasts peek or overlap behind the active toast.

Presets are layered under @layer toast-queue, so your own styles can override them.

Bundler

import 'toast-queue/presets/list.css'; import 'toast-queue/presets/stacked.css'; Copy code

CDN

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/toast-queue@1/dist/presets/list.min.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/toast-queue@1/dist/presets/stacked.min.css"> Copy code

Using toast-queue without a bundler

Load the package directly from a CDN. This is useful for static sites, prototypes, and progressively enhanced applications.

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/toast-queue@1/dist/toast-queue.min.css"> <script type="module"> import { ToastQueue } from 'https://cdn.jsdelivr.net/npm/toast-queue@1/+esm'; const toastQueue = new ToastQueue(); // ... </script> Copy code

Accessibility

Toasts are announced to assistive technologies when supported by the browser. The queue also manages interaction states so a toast can be inspected or interacted with without being immediately dismissed.

toast-queue uses modern browser APIs and progressively enhances them. Where supported animation or transition APIs are unavailable, the toast still renders and remains functional.

If ariaNotify() is not available, you can load the @github/arianotify-polyfill conditionally before creating the queue:

if (typeof HTMLElement.prototype.ariaNotify !== 'function') { await import('@github/arianotify-polyfill'); } const toastQueue = new ToastQueue(); Copy code

Need more?

For the complete API, including queue options, toast options, methods, properties, and template hooks, see the API reference.