Skip to content

BoeunHan/mole-toast

Repository files navigation

mole-toast

Lightweight toast notification library for React


Features

  • Simple toast API
  • Supports multiple toast types and durations

Demo

Live Preview

Mole Toast Demo

Toast Types

Type Preview
Success Success
Error Error
Info Info
Warning Warning

Installation

npm install mole-toast
# or
yarn add mole-toast

Usage

Import ToastProvider and ToastManager to root layout

import { ToastProvider, ToastManager } from "mole-toast";

export default function RootLayout({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <html lang="ko">
      <body>
        <ToastProvider>
          {children}
          <ToastManager />
        </ToastProvider>
      </body>
    </html>
  );
}

Use the toast hook inside of ToastProvider:

import React from "react";
import { useToast, ToastManager } from "mole-toast";

function DemoButton() {
  const toast = useToast();

  return (
    <button onClick={() => toast.shortSuccess("This is a success message!")}>
      Show Success Toast
    </button>
  );
}

export default App;

Toast API

  • longSuccess(message: string)
  • longError(message: string)
  • longInfo(message: string)
  • longWarning(message: string)
  • shortSuccess(message: string)
  • shortError(message: string)
  • shortInfo(message: string)
  • shortWarning(message: string)
  • clear() - clear all toasts in state

Peer Dependencies

This library requires the following peer dependencies to be installed in your project:

React (>=17)


License

MIT © Boeun Han

About

Lightweight toast notification library for React

Topics

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
LICENSE-FeatherIcons

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published