Skip to content

mk-saadi/react-toast-master

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

40 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

React-Toast-Master

πŸ† React's most customizable toast component!

Installation

$ npm install react-toast-master
$ yarn add react-toast-master

πŸ’‘ Simple Example

import React from "react";
import { ToastProvider, useToast } from "react-toast-master";

function App() {
	const { toastMaster } = useToast();

	const showToast = () => {
		toastMaster({
			type: "success",
			message: "Hello World!",
		});
	};

	return (
		<ToastProvider>
			<button onClick={showToast}>Toast</button>
		</ToastProvider>
	);
}

πŸ’‘ With More Customization ( with Tailwind CSS )

import React from "react";
import { ToastProvider, useToast } from "react-toast-master";

function App() {
	const { toastMaster } = useToast();

	const showToast = () => {
		toastMaster({
			type: "errorWhite",
			message: "Uh oh! Something went wrong.",
			footer: (
				<div className="flex justify-between w-full">
					<p>There was a problem with your request.</p>{" "}
					<span className="border border-white cursor-pointer duration-100 hover:bg-white hover:text-[#dc2626] h-min px-2 rounded-sm text-white whitespace-nowrap">
						Try again
					</span>
				</div>
			),
			align: "left",
			position: "bottomRight",
			bg: "error",
			transition: "top",
			shadow: "white",
			cancelButton: true,
		});
	};

	return (
		<ToastProvider>
			<button onClick={showToast}>Toast</button>
		</ToastProvider>
	);
}

πŸ“” Documentation and Demo

Check website to get a better understanding!

πŸ“œ License

Licensed under MIT