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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-mui-snackbar

v4.0.0

Published

Easier way to display MUI Snackbar across your app thanks to Context API

Downloads

31

Readme

React MUI Snackbar

Version 4.0.0 Released

This new version is a major update.

Breaking changes

openSnackbar method has been updated. It do not take duration as parameter anymore. Duration is now a prop of SnackbarProvider to have the same behavior across your app.

New features

SnackbarProvider changes :

  • SnackbarProvider now take a position prop to define the position of the snackbar.
  • SnackbarProvider now take a duration prop to define the duration of the snackbar.
  • SnackbarProvider is returned with a memo to avoid re-rendering of the provider.

Snackbar changes :

  • Snackbar handle default style if severity is not provided.
  • Snackbar handle severity style if severity is provided.
  • Snackbar transition is now a slide in.
  • Snackbar is returned with a memo to avoid re-rendering of the snackbar.
  • Snackbar style can be change with MUI theme.

All functions are under useCallback to avoid re-rendering of the component and get better performance.

Description

React MUI Snackbar is the greatest library to handle notifications in your React app. It has been built with Material UI and React. Thanks to the library you will increase your productivity, your app will be more user friendly and you will increase your user experience ! Open a notification is now VERY VERY easy and FAST.

With React MUI Snackbar you can display cool notification in your app. You can choose the position and the duration of the notification by using the SnackbarProvider.

Everything has been think to be performant, cool and easy to use. It provides you a simple method which is openSnackbar to open a notification.

openSnackbar method takes two parameters :

  • message : the message to display in the notification
  • severity : the severity of the notification. It can be success, info, warning or error. If not provided, the notification will be displayed with default style.

Everything is customizable. You can change the style of the notification with MUI theme.

Moreover, typescript is 100% supported.

NPM Version Installed size Vulnerabilities count

MIT License

Demo

View demo here

Setup

// Create your react app with SnackbarProvider
import {StrictMode} from 'react';
import {createRoot} from 'react-dom/client';
import App from './App';
import {BrowserRouter} from 'react-router-dom';
import SnackbarProvider  from "react-mui-SnackbarContent" ;

createRoot(document.getElementById('root')).render(
    <StrictMode>
        <BrowserRouter>
            <SnackbarProvider
                duration={6000}
                position={{
                    vertical:'bottom', 
                    horizontal:'right'
            }}
            >
                <App />
            </SnackbarProvider>
        </BrowserRouter>
    </StrictMode>
);

Usage

// Use the Snackbar context to get openSnackbar method.
import {useSnackbarContext} from "react-mui-SnackbarContent";

function App() {

    const {openSnackbar} = useSnackbarContext() ;

    return (
        <div>
            <button onClick={() => {
                openSnackbar({
                    message:'I love MUI Snackbar',
                    severity:''
                })
            }}>
                open snackbar
            </button>
        </div>
    )
}

export default App;

Function parameters

SnackbarProvider props

| Parameter | Type | Description | Default | | :-------- | :------- | :-------------------------------- |------------------------------------------| | duration | number | The duration of the snackbar in ms | 6000 | | position | SnackbarOrigin | The position of the snackbar | {vertical:'bottom', horizontal:'left'} |

vertical can be : top or bottom horizontal can be : left or right

openSnackbar methods

| Parameter | Type | Description | Default | | :-------- | :------- | :-------------------------------- |---------| | message | string | Required. The message to display | null | | severity | AlertColor | It can be success, info, warning or error | none |

Severity is not mandatory. It will display default style of snackbar message if not provided.

Next steps - Coming soon

  • Unit test