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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@leafygreen-ui/toast

v7.0.5

Published

leafyGreen UI Kit Toast

Downloads

270,575

Readme

Toast

npm (scoped)

View on MongoDB.design

Installation

Yarn

yarn add @leafygreen-ui/toast

NPM

npm install @leafygreen-ui/toast

Example

import Button from '@leafygreen-ui/button';
import { ToastProvider, useToast, Variant } from '@leafygreen-ui/toast';

const { pushToast, clearStack, getStack, updateToast } = useToast();
const stack = getStack();

const createToast = () => {
  pushToast({
    title: 'Toast Title',
    description: 'Toast Description',
    variant: Variant.Success,
    timeout: null,
  });
};

return (
  <ToastProvider>
    <Button onClick={createToast}>Create toast</Button>
  </ToastProvider>
);

Properties, useToast

useToast is a React hook that enables a consumer to interact with a Toast stack. It may only be used inside of a <ToastProvider />. The hook takes no arguments and returns the following functions:

| Name | Signature | | ----------- | ------------------------------------------------------------------------ | | pushToast | (payload: ToastProps) => ToastId | | popToast | (payload: ToastId) => ToastProps \| undefined | | updateToast | (id: ToastId, props: Partial<ToastProps>, ) => ToastProps \| undefined | | getToast | (id: ToastId) => ToastProps \| undefined | | getStack | () => ToastStack \|undefined | | clearStack | () => void |

Properties, ToastProvider

| Prop | Type | Default | Description | | --------------- | ------------------------- | ------- | ----------------------------------------------------- | | initialValue | Map<ToastId, ToastProps>; | | The initial toasts in the stack. | | portalClassName | string | | Class name applied to the containing Portal component |

Properties, Controlled Toast

| Prop | Type | Default | Description | | ---------------- | --------------------------------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | actionElement | React.ReactNode | | Optional action button, or other element. Only rendered if variant === 'progress'. This should be a shortcut only—and not the only way to perform the action. The provided action element should have an aria-description attribute that describes how to alternatively perform the action. | | darkMode | boolean | false | Renders the component with dark mode styles. | | description | React.ReactNode | | Additional body text | | dismissible | boolean | true | Determines whether to render the close button. If timeout === null, then dismissible is forced to true. | | onClose | (event: ToastCloseEvent) => void | | Fired either when the close button is clicked, or when timeout has elapsed. When triggered by button click, event.type === "click". When triggered by timeout, event.type === "timeout". | | open required | boolean | | Required boolean that renders the Toast and makes it visible when true. Note: open is not a valid prop when rendering toasts programmatically | | progress | number | | Optional number between 0 and 1 that sets the progress bar's progress. Note: the progress bar is only rendered when the Toast variant is set to 'progress'. | | timeout | number \| null | 6000 | Dismiss the Toast after timeout milliseconds. If timeout is null or 0, the Toast will never dismiss automatically. Notes: when variant="progress", timeout timer will not start until progress is complete.timeout timer will be paused when a user is interacting with a Toast. | | title required | React.ReactNode | | Primary text for the toast | | variant | 'success' 'note' 'warning' 'progress' 'important' | note | Required style variant to render the Toast as. |