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

@m3e/snackbar

v1.1.2

Published

Snackbar for M3E

Readme

@m3e/snackbar

The @m3e/snackbar package provides the M3eSnackbar global service on window (globalThis) used to present short updates about application processes at the bottom of the screen from anywhere in an application.

This package is part of M3E monorepo, a unified suite of Material 3 web components. Explore the docs to see them in action.

📦 Installation

npm install @m3e/snackbar

💻 Editor Integration

This package includes a Custom Elements Manifest to support enhanced editor tooling and developer experience.

Visual Studio Code

To enable autocomplete and hover documentation for @m3e/snackbar, install the Custom Elements Manifest Language Server extension. It will automatically detect the manifest bundled with this package and surface tag names, attributes, slots, and events in supported files.

Alternately, you can explicitly reference the html-custom-data.json and css-custom-data.json in your workspace settings:

{
  "html.customData": ["./node_modules/@m3e/snackbar/dist/html-custom-data.json"],
  "css.customData": ["./node_modules/@m3e/snackbar/dist/css-custom-data.json"]
}

🚀 Native Module Support

This package uses JavaScript Modules. To use it directly in a browser without a bundler, use a module script similar to the following.

<script type="module" src="/node_modules/@m3e/snackbar/dist/index.js"></script>

You also need a module script for @m3e/button and @m3e/icon-button due to being a dependency.

<script type="module" src="/node_modules/@m3e/button/dist/index.js"></script>
<script type="module" src="/node_modules/@m3e/icon-button/dist/index.js"></script>

In addition, you must use an import map to include additional dependencies.

<script type="importmap">
  {
    "imports": {
      "lit": "https://cdn.jsdelivr.net/npm/[email protected]/+esm",
      "@m3e/core": "/node_modules/@m3e/core/dist/index.js"
    }
  }
</script>

For production, use index.min.js for faster load times.

🧪 Examples

The following example illustrates basic usage.

M3eSnackbar.open("File deleted");

The next example illustrates presenting a snackbar with an action and callback.

M3eSnackbar.open("File deleted", "Undo", {
  actionCallback: () => {
    // Undo logic here
  },
});

📖 API Reference

🛠️ Snackbar Service

This section details the methods available for the M3eSnackbar service.

⚙️ Methods

| Method | Signature | Description | | --------- | ---------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | open | open(message: string, options?: SnackbarOptions): void | Opens a snackbar with a message.- message: The message to show in the snackbar.- options: (optional) Options that control the behavior of the snackbar. | | open | open(message: string, action: string, options?: SnackbarOptions): void | Opens a snackbar with a message and action.- message: The message to show in the snackbar.- action: The label for the snackbar action.- options: (optional) Options that control the behavior of the snackbar. | | open | open(message: string, action: string, dismissible: boolean, options?: SnackbarOptions): void | Opens a snackbar with a message, action, and optional close affordance.- message: The message to show in the snackbar.- action: The label for the snackbar action.- dismissible: Whether to present close affordance.- options: (optional) Options that control the behavior of the snackbar. | | open | open(message: string, dismissible: boolean, options?: SnackbarOptions): void | Opens a snackbar with a message and optional close affordance.- message: The message to show in the snackbar.- dismissible: Whether to present close affordance.- options: (optional) Options that control the behavior of the snackbar. | | dismiss | dismiss(): void | Dismisses the currently visible snackbar. |

🗂️ Snackbar

This section details the attributes, slots and CSS custom properties available for the m3e-snackbar component.

⚙️ Attributes

| Attribute | Type | Default | Description | | ------------- | --------- | --------- | ------------------------------------------------------------------------------------------ | | action | string | | The label of the snackbar's action. | | close-label | string | "Close" | The accessible label given to the button used to dismiss the snackbar. | | dismissible | boolean | false | Whether a button is presented that can be used to close the snackbar. | | duration | number | 3000 | The length of time, in milliseconds, to wait before automatically dismissing the snackbar. |

🧩 Slots

| Slot | Description | | ------------ | -------------------------------------- | | (default) | Renders the content of the snackbar. | | close-icon | Renders the icon for the close button. |

🎛️ CSS Custom Properties

| Property | Description | | -------------------------------------------- | -------------------------------------------- | | --m3e-snackbar-margin | Vertical offset from the bottom of viewport. | | --m3e-snackbar-container-shape | Border radius of the snackbar container. | | --m3e-snackbar-container-color | Background color of the snackbar. | | --m3e-snackbar-padding | Internal spacing of the snackbar container. | | --m3e-snackbar-min-width | Minimum width of the snackbar. | | --m3e-snackbar-max-width | Maximum width of the snackbar. | | --m3e-snackbar-supporting-text-font-size | Font size for supporting text. | | --m3e-snackbar-supporting-text-font-weight | Font weight for supporting text. | | --m3e-snackbar-supporting-text-line-height | Line height for supporting text. | | --m3e-snackbar-supporting-text-tracking | Letter spacing for supporting text. | | --m3e-snackbar-supporting-text-color | Color of supporting text. | | --m3e-snackbar-action-text-color | Color of the action button text. | | --m3e-snackbar-close-icon-color | Color of the close icon. |

🤝 Contributing

See the root monorepo CONTRIBUTING.md for guidelines on contributing to this package.

📄 License

This package is licensed under the MIT License.