UNPKG

mayank-ui

Version:

Advanced React Toast UI with animations and auto-dismiss

91 lines (62 loc) โ€ข 2.37 kB
# ๐Ÿฅช mayank-ui โ€” React Toast Notification Library **mayank-ui** is a lightweight, customizable React toast notification library with smooth animations and built-in themes. Ideal for alerting users about success, errors, warnings, and info messages โ€” all with just one simple API. --- ## ๐Ÿ“ฆ Installation Install via **npm**: ```bash npm install mayank-ui ``` ## ๐Ÿ› ๏ธ Usage #### 1. Import the CSS (Required) Add this line at the top of your main file (main.jsx, index.js, or App.jsx): ```bash import 'mayank-ui/dist/index.css'; ``` #### 2. Setup the ToastManager Component You need to include the ToastManager component once in your component tree (usually at the top level): ```bash import React from 'react'; import { ToastManager, toast } from 'mayank-ui'; import 'mayank-ui/dist/index.css'; const App = () => { return ( <div style={{ padding: '2rem' }}> <ToastManager /> <h2>Hello, Mayank's Toast Demo ๐Ÿž</h2> <button onClick={() => toast('โœ… Success toast!', { type: 'success' })}> Show Success </button> <button onClick={() => toast('โŒ Error occurred!', { type: 'error' })}> Show Error </button> <button onClick={() => toast('โš ๏ธ Warning ahead!', { type: 'warning' })}> Show Warning </button> <button onClick={() => toast('โ„น๏ธ Just some info', { type: 'info' })}> Show Info </button> </div> ); }; export default App; ``` ### ๐Ÿงพ Available Options | Option | Type | Default | Description | |------------|----------|---------|--------------------------------------------------------------| | `type` | `string` | `"info"`| Type of toast โ€” `"success"`, `"error"`, `"warning"`, or `"info"` | | `duration` | `number` | `3000` | Auto-dismiss duration in milliseconds | ## ๐ŸŒˆ Styling There are 4 default toast types, each styled with a different color: โœ… success โŒ error โš ๏ธ warning โ„น๏ธ info If you want to override the styles, you can: Copy and edit index.css from the package. Use your own custom classNames and styles in the toast renderer (advanced). ## ๐Ÿš€ Build Your Own This package is built with: React Rollup Babel PostCSS