Toast

An accessible and beautiful toast library for React.

View on GitHub

Framework guides

Getting Started

  1. Install the library:
# Using npm:
npm install @pheralb/toast
 
# Using pnpm:
pnpm add @pheralb/toast
 
# Using yarn:
yarn add @pheralb/toast
  1. Add the toast provider:
// 📃 main.tsx
import { ToastProvider } from '@pheralb/toast';
 
ReactDOM.createRoot(document.getElementById('root')!).render(
  <React.StrictMode>
    <ToastProvider>
      <App />
    </ToastProvider>
  </React.StrictMode>,
);
  1. Usage:
// 📃 index.tsx
export default function Index() {
  const toast = useToast();
  return (
    <>
      <button
        onClick={() =>
          toast.success({
            text: 'pheralb/toast',
            description: '✨ A beautiful toast library for React',
          })
        }
      >
        <span>Render a toast</span>
      </button>
    </>
  );
}