npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@spectrum-web-components/toast

v1.12.2

Published

`<sp-toast>` elements display brief, temporary notifications. They are noticeable but do not disrupt the user experience and do not require an action to be taken.

Readme

Overview

<sp-toast> elements display brief, temporary notifications. They are noticeable but do not disrupt the user experience and do not require an action to be taken.

Usage

See it on NPM! How big is this package in your project? Try it on Stackblitz

yarn add @spectrum-web-components/toast

Import the side effectful registration of <sp-toast> via:

import '@spectrum-web-components/toast/sp-toast.js';

When looking to leverage the Toast base class as a type and/or for extension purposes, do so via:

import { Toast } from '@spectrum-web-components/toast';

Anatomy

The toast consists of two key parts:

  • The message content in its default slot
  • An optional action button using slot="action"

Content

The message in its default slot:

<sp-toast open>
  This is important information that you should read, soon.
</sp-toast>

Action Button

An optional action using slot="action":

<sp-toast open>
  This is important information that you should read, soon.
  <sp-button
    slot="action"
    static-color="white"
    variant="secondary"
    treatment="outline"
  >
    Do something
  </sp-button>
</sp-toast>

Options

Width and Wrapping

The toast can be constrained to a specific width, and its content will wrap accordingly:

<sp-toast open style="width: 300px">
  This is important information that you should read, soon.
  <sp-button
    slot="action"
    static-color="white"
    variant="secondary"
    treatment="outline"
  >
    Do something
  </sp-button>
</sp-toast>

Variants

By default, the toast is rendered in gray and does not have an icon. This is used when the message is neutral in tone or when its semantics do not fit in any of the other variants.

However, the toast supports several variants to convey different types of messages:

Use variant="negative" to show an error or failure.

<sp-toast open variant="negative">
  This is negative information that you should read, soon.
</sp-toast>

Use variant="positive" to show a successful action or completion of a task.

<sp-toast open variant="positive">
  This is positive information that you should read, soon.
</sp-toast>

Use variant="info" to show an informative message.

<sp-toast open variant="info">
  This is information that you should read.
</sp-toast>

Behaviors

Timeout

The toast can be configured to automatically dismiss itself after a specified duration. For accessibility reasons, the minimum timeout is 6000ms (6 seconds). For longer messages, it's recommended to add 1000ms for every 120 words.

<sp-toast open timeout="6000">
  This message will disappear after 6 seconds.
</sp-toast>

Close Events

The toast dispatches a close event when it's being closed, either by user action or timeout. This event can be prevented using event.preventDefault().

Accessibility

Keyboard Interaction

The toast supports keyboard navigation:

  • When an action button is present, it can be accessed using the Tab key
  • The close button (when present) can be activated using Enter or Space

Place toasts in a region

The <sp-toast> element is rendered with a role of alert to notify screen readers. When rendering a toast on a page, it should be placed in a container with a role of region for better accessibility.

<div role="region" aria-label="Toast Notifications">
  <sp-toast open>
    This is important information that you should read, soon.
  </sp-toast>
</div>

Allow time for reading

Accessibility concerns require that a Toast is available for at least 6000ms before being dismissed.

The toast ensures that messages are visible for a minimum of 6 seconds to give users enough time to read and comprehend the information. For longer messages, the timeout is automatically extended.

It is suggested that messages longer than 120 words should receive an additional 1000ms in their timeout for each additional 120 words in the message.

For example, a message with 240 words should have a timeout of 7000ms, and a message with 360 words should have a timeout of 8000ms.

Provide appropriate labels

  • The toast's variant icon includes an appropriate icon-label for screen readers (e.g., "Information" for info variant)
  • Action buttons should have clear, descriptive labels
<sp-toast open variant="negative" icon-label="Warning">
  This is important information that you should read, soon.
  <sp-button
    slot="action"
    static-color="white"
    variant="secondary"
    treatment="outline"
  >
    Ignore warning
  </sp-button>
</sp-toast>