UNPKG

@divetocode/toast

Version:

A lightweight toast notification system for React/Next.js

87 lines (55 loc) • 1.68 kB
# @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)