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

react-bugle

v0.1.1

Published

React notification component with context-based state management

Readme

react-bugle

A simple React notification component.

✅ Context-based state management
✅ Push notifications from inside or outside React components
✅ Custom styles
✅ Button controls with optional callback on confirmation

Demo

Open demo

Installation

npm install react-bugle

Builds

Four builds are available depending on your needs:

| Import | Icons | styled-components | | ------ | ----- | ----------------- | | react-bugle | ✅ default icons via react-icons | bundled | | react-bugle/iconless | ❌ no icons | bundled | | react-bugle/themed | ✅ default icons via react-icons | external (peer) | | react-bugle/themed-iconless | ❌ no icons | external (peer) |

The themed builds require styled-components >=5.1 to be installed in your project. This gives you a single shared instance of styled-components, which is necessary if you want to access your app's theme values in custom styles via props.theme.

The default builds bundle styled-components, so no extra install is needed — but props.theme access in custom styles will not work.

Usage

Wrap your app in NotificationsProvider and include the Notifications component anywhere inside it.

import Notifications, { NotificationsProvider } from 'react-bugle'

const App = () => (
  <NotificationsProvider>
    <Notifications />
    {/* rest of your app */}
  </NotificationsProvider>
)

Props

| name | type | description | | ------ | ------ | ------------------------ | | styles | object | (optional) custom styles | | icons | object | (optional) custom icons |

Pushing a notification from a React component

import { useNotifications } from 'react-bugle'

const MyComponent = () => {
  const { push } = useNotifications()

  return (
    <button onClick={() => push({
      id: Date.now(),
      type: 'success',
      label: 'It worked!',
      duration: 10000
    })}>
      Show notification
    </button>
  )
}

Pushing a notification from outside React

import { notificationBridge } from 'react-bugle'

notificationBridge.push({
  id: Date.now(),
  type: 'error',
  label: 'Something went wrong'
})

Pushing a notification with button controls

push({
  id: Date.now(),
  type: 'error',
  label: 'Are you sure?',
  buttons: 'ok' // valid options: 'yesNo' or 'ok'
})

Running a callback when a notification is confirmed

push({
  id: Date.now(),
  type: 'info',
  label: 'Delete this item?',
  buttons: 'yesNo',
  payload: () => deleteItem(id) // called when the Yes button is clicked
})

Dismissing a notification manually

// from inside React
const { pop } = useNotifications()
pop(notificationId)

// from outside React
notificationBridge.pop(notificationId)

Notification properties

| name | type | description | | -------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------- | | id | any | Unique notification ID | | type | string | Notification type. Choose from 3 built-in types: 'success', 'info', 'error' or create a custom type by declaring it in the styles prop | | label | string | Notification label | | duration | number | (optional) Display duration in milliseconds, default 5000. Ignored when buttons is set | | buttons | string | (optional) Show button controls. Options: 'yesNo', 'ok'. Prevents auto-dismiss | | payload | function | (optional) Callback invoked when the Yes or Ok button is clicked | | blocking | boolean | (optional) Show a darkened overlay behind the notification |

Complete styling example

import Notifications, { createNotificationStyle } from 'react-bugle'

const styles = {
  container: (defaults) => ({
    ...defaults,
    alignItems: 'flex-end'
  }),
  containerInner: (defaults) => ({
    ...defaults,
    bottom: '45px'
  }),
  overlay: (defaults) => ({
    ...defaults,
    background: 'darkgray'
  }),
  // add a custom notification type with createNotificationStyle
  customStyle1: createNotificationStyle('purple', 'fuchsia', true),
  // or set every property manually
  customStyle2: {
    notification: (defaults) => ({
      ...defaults,
      background: 'burlywood'
    }),
    notificationInner: (defaults) => ({
      ...defaults,
      minHeight: '100px'
    }),
    icon: (defaults) => ({
      ...defaults,
      fontSize: '40px',
    }),
    label: (defaults) => ({
      ...defaults,
      color: 'brown'
    }),
    buttonsOuter: (defaults) => ({
      ...defaults,
      background: 'red'
    }),
    button: (defaults) => ({
      ...defaults,
      fontSize: '20px'
    })
  },
  // override the default 'error' type
  error: {
    ...createNotificationStyle(
      'red',  // primary color
      'blue', // secondary color
      true    // set to false to disable the background animation
    ),
    label: (defaults) => ({
      ...defaults,
      color: 'black',
      fontSize: '20px'
    })
  }
}

const icons = {
  customStyle1: <>🐼</>,
  customStyle2: <>🥒</>,
  success: null, // no icon for success
}

const App = () => <Notifications styles={styles} icons={icons} />

License

MIT