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

react-snackify

v1.0.17

Published

A lightweight, customizable React Snackbar component with Tailwind CSS support.

Downloads

105

Readme

react-snackify

React Snackify made easy! 🚀 Display customizable snackbar notifications in your React applications with minimal setup.

Demo

See it in action! Try our interactive playground to customize and preview snackbars in real-time: Explore the Demo

Installation

Install the package via npm or yarn:

npm install react-snackify

or

yarn add react-snackify

Don't forget to import the CSS styles:

import "react-snackify/styles/snack-bar.css";

Features

  • Easy Setup: Wrap your app with SnackbarProvider and use the useSnackbar hook to show notifications.
  • Highly Customizable: Supports multiple animation types (fade, slide, scale, grow), style variants (default, neon-glow, holographic, bold-monochrome, vintage-paper, glassmorphism), and custom icons per variant.
  • Positions: Place snackbars at top-left, top-right, top-center, bottom-left, bottom-right, or bottom-center.
  • Variants: Success, error, warning, info with corresponding colors and icons.
  • Actions: Add one or more buttons with custom labels, icons, onClick handlers, and auto-dismiss options.
  • AutoMorph: Automatically transform the snackbar after a delay (e.g., from info to success).
  • Progress Bar: Visual timer that pauses on hover.
  • Update & Close: Programmatically update or close specific snackbars.
  • Priority System: Handle overlapping notifications with priority levels.
  • Accessible: keyboard support (Escape to close), and polite live regions.
  • Async Support: Show loading states and update based on promises.
  • No Dependencies: Lightweight and works with React 16+.

Usage

Basic Setup

Wrap your application with SnackbarProvider to enable snackbars globally.

import React from "react";
import { SnackbarProvider } from "react-snackify";
import "react-snackify/styles/snack-bar.css";

function App() {
  return (
    <SnackbarProvider globalPosition="bottom-center">
      {/* Your app components */}
    </SnackbarProvider>
  );
}

export default App;

Showing a Snackbar

Use the useSnackbar hook inside a component to show notifications.

import React from "react";
import { useSnackbar } from "react-snackify";

function MyComponent() {
  const { showSnackbar } = useSnackbar();

  const handleClick = () => {
    showSnackbar({
      message: "This is an info message!",
      variant: "info",
      duration: 3000,
    });
  };

  return <button onClick={handleClick}>Show Snackbar</button>;
}

SnackbarProvider Props

| Prop | Type | Default | Description | | ---------------- | --------------------------------------------------------------------------------------------------------- | ----------- | ------------------------------------------------------ | | children | React.ReactNode | - | The content to wrap (your app). | | globalPosition | 'top-left' \| 'top-right' \| 'top-center' \| 'bottom-left' \| 'bottom-right' \| 'bottom-center' | - | Default position for all snackbars. | | animationType | 'fade' \| 'slide' \| 'scale' \| 'grow' | 'slide' | Animation style for entering/exiting. | | styleVariant | 'default' \| 'neon-glow' \| 'holographic' \| 'bold-monochrome' \| 'vintage-paper' \| 'glassmorphism' | 'default' | Visual theme for snackbars. | | iconSet | { success?: ReactNode; error?: ReactNode; warning?: ReactNode; info?: ReactNode; loading?: ReactNode; default?: ReactNode; } | - | Custom icons for each variant (falls back to default). | | maxSnack | number | 5 | Maximum number of snackbars displayed simultaneously.

showSnackbar Options

The showSnackbar function returns a controller with update and close methods.

| Option | Type | Default | Description | | ----------- | ------------------------------------------------------------------------------------------------- | --------------------------- | ------------------------------------------------ | | id | string | Auto-generated | Unique identifier for updating/closing. | | classname | string | '' | Additional CSS classes for the snackbar. | | message | string \| React.ReactNode | - | The content to display. | | variant | 'success' \| 'error' \| 'warning' \| 'info' \| 'loading' | 'info' | Notification type (affects color/icon). | | position | 'top-left' \| 'top-right' \| 'top-center' \| 'bottom-left' \| 'bottom-right' \| 'bottom-center' | Provider's globalPosition | Placement on screen. | | duration | number | 3000 | Time in ms before auto-dismiss (0 for infinite). | | action | SnackbarAction \| SnackbarAction[] | - | Button(s) with label, onClick, icon, etc. | | priority | number | 0 | Higher priority replaces existing with same ID. | | autoMorph | { to?: SnackbarShowOptions; after?: number; } | - | Transform to new options after a delay. |

SnackbarAction Interface

| Field | Type | Default | Description | | ------------- | ----------------- | ------- | --------------------------- | | label | string | - | Button text. | | onClick | () => void | - | Click handler. | | autoDismiss | boolean | true | Close snackbar after click. | | ariaLabel | string | Label | Accessibility label. | | icon | React.ReactNode | - | Optional icon before label. |

Advanced Examples

Custom Icons and Styles

import React from "react";
import { SnackbarProvider } from "react-snackify";

<SnackbarProvider
  globalPosition="bottom-center"
  animationType="grow"
  styleVariant="neon-glow"
  iconSet={{
    success: <img src="/success-icon.svg" alt="Success" />,
    error: <span>❌</span>,
    warning: <span>⚠️</span>,
    info: <span>ℹ️</span>,
    default: <span>🔔</span>,
  }}
>
  {/* App */}
</SnackbarProvider>;

With Actions

import { useSnackbar } from "react-snackify";

const { showSnackbar } = useSnackbar();

showSnackbar({
  message: "Action required!",
  variant: "warning",
  action: [
    {
      label: "Undo",
      onClick: () => console.log("Undo clicked"),
      icon: <span>↩️</span>,
    },
    {
      label: "Dismiss",
      onClick: () => console.log("Dismissed"),
      autoDismiss: true,
    },
  ],
});

Async Updates

import { useSnackbar } from "react-snackify";

const { showSnackbar } = useSnackbar();

const handleAsync = async () => {
  const snack = showSnackbar({
    message: "Uploading...",
    variant: "info",
    duration: 0, // Infinite until updated
  });
  try {
    await someApiCall();
    snack.update({
      message: "Upload complete ✅",
      variant: "success",
      duration: 3000,
    });
  } catch {
    snack.update({
      message: "Upload failed ❌",
      variant: "error",
      duration: 4000,
    });
  }
};

AutoMorph Example

import { useSnackbar } from "react-snackify";

const { showSnackbar } = useSnackbar();

showSnackbar({
  message: "Processing...",
  variant: "info",
  autoMorph: {
    after: 3000,
    to: {
      message: "Upload complete ✅",
      variant: "success",
      duration: 3000,
    },
  },
});

Contribute

If you find this useful, star the repo!
Suggestions and PRs are welcome — check the Contributing Guide for details.

License

This project is licensed under the MIT License.