mayank-ui
Version:
Advanced React Toast UI with animations and auto-dismiss
91 lines (62 loc) โข 2.37 kB
Markdown
# ๐ฅช 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