@divetocode/toast
Version:
A lightweight toast notification system for React/Next.js
87 lines (55 loc) ⢠1.68 kB
Markdown
# @divetocode/toast
> A lightweight, beautiful toast notification system for React & Next.js ā powered by emotion, built for speed.
## ⨠Features
- ā” Lightweight & fast
- šØ Simple, modern design
- š§ Intuitive API: `showToast()`, `<ToastRoot />`
- šÆ Fully compatible with React & Next.js
- šļø Custom color & emoji support (ā
ā etc.)
---
## š¦ Install
```bash
npm install @divetocode/toast
```
## šÆ Usage
### 1. Add the ToastRoot once in your app layout:
```tsx
import { ToastRoot } from "@divetocode/toast";
export default function App({ Component, pageProps }) {
return (
<>
<ToastRoot />
<Component {...pageProps} />
</>
);
}
```
### 2. Trigger a toast anywhere:
```tsx
import { showToast } from "@divetocode/toast";
<button onClick={() => showToast("ā
Copy success!")}>
Copy
</button>
```
## šØ Customization
| Type | Default Appearance |
| ------- | ---------------------- |
| success | ā
Green (copy success) |
| error | ā Red (failure toast) |
```bash
showToast("ā Failed to copy", { type: "error" });
```
## š Folder structure
src/
āāā Toast.tsx
āāā ToastRoot.tsx
āāā showToast.ts
āāā index.ts
## š License
MIT Ā© divetocode
## š¤ From divetocode
Built to feel right in design systems & product codebases.
Use it, fork it, and toast your users the beautiful way.
## š¦ Package
**npm:** [`@divetocode/toast`](https://www.npmjs.com/package/@divetocode/toast)
**GitHub:** [`divetocode/divetocode-toast`](https://github.com/divetocode/divetocode-toast)