Skip to content

Latest commit

 

History

History
54 lines (34 loc) · 1.31 KB

README.md

File metadata and controls

54 lines (34 loc) · 1.31 KB

useToast Hook for MUI

Hooks for super easy use of MUI's Snackbar.

Installation

npm install use-toast-mui

Setup

<ToastProvider>
  <App />
</ToastProvider>

useToast

useToast provides a function to display a Snackbar with Alert.

const ExampleButton = () => {
  const toast = useToast()
  return <button onClick={() => toast.success("hello!")}>
    push me
  </button>
}

API

success(message: string)

image

warning(message: string)

image

info(message: string)

image

error(message: string)

image

show(message: string, options: { severity: AlertColor })

show accepts the severity as a parameter.

show("hello", { severity: "info" }) is equivalent to info("hello")