noti-toast
v1.1.0
Published
A dynamic, interactive notification library with fluid SVG path morphing animations.
Maintainers
Readme
Noti 🔔✨
A sleek, premium, highly interactive React and Tailwind CSS notification library featuring fluid SVG path morphing animations, spring-based motion, and intelligent stackable notification decks.
✨ Features
- Fluid SVG Path Morphing: The background container shape adapts fluidly as content expands, collapses, or transitions between states.
- Interactive Staggered Decks: Multiple active notifications stack neatly in 3D decks and expand dynamically when hovered.
- Flexible Positioning: Supports 6 responsive screen locations:
top-left,top-center,top-right,bottom-left,bottom-center, andbottom-right. - Pre-styled Theme Support: Beautiful preconfigured templates for
success,error,warning, andinfotypes, automatically adapting to light/dark themes. - Developer Debug Mode: Append
?debug=trueto your application URL to inspect morphing vectors and boundaries in real-time. - Zero Jitter: Built using rounded sub-pixel measurements to ensure animations are free of rendering wobble.
📦 Installation
To install the library in your project:
npm install noti-toast🚀 Configuration
1. Update Tailwind CSS Content Paths
Because noti utilizes Tailwind utility classes, your application's Tailwind CSS compiler must scan the library's compiled source code. Add the node_modules location to your tailwind.config.js or tailwind.config.ts:
// tailwind.config.js
module.exports = {
content: [
"./src/**/*.{js,ts,jsx,tsx}", // Your app's files
"./node_modules/noti-toast/dist/**/*.{js,ts,jsx,tsx}" // Add this line!
],
theme: {
extend: {},
},
plugins: [],
}🛠️ Usage
1. Add the Viewport Component
Mount the NotiRoot component near the root of your application layout (e.g., inside layout.tsx or App.tsx) to serve as the rendering portal for all active notification streams.
// app/layout.tsx
import { NotiRoot } from 'noti-toast'
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>
{children}
{/* Notification rendering portal with custom defaults and hover pause toggle */}
<NotiRoot position="top-right" duration={3000} pauseOnHover={true} />
</body>
</html>
)
}2. Triggering Notifications
Import the global noti controller in any component or function to trigger responsive, beautifully styled notifications.
"use client"
import { noti } from 'noti-toast'
export default function ActionButton() {
const triggerSuccess = () => {
noti.success("Build compiled successfully!", {
title: "Success",
position: "top-right",
duration: 5000,
action: {
label: "View logs",
onClick: (id) => console.log("Notification closed:", id)
}
})
}
const triggerError = () => {
noti.error("Failed to establish server connection.", {
title: "Connection Failed",
position: "bottom-center"
})
}
return (
<div className="flex gap-4">
<button onClick={triggerSuccess}>Success Notification</button>
<button onClick={triggerError}>Error Notification</button>
</div>
)
}📖 API Reference
noti(message: string, options?: NotiOptions)
Triggers a base information notification.
NotiOptions
| Option | Type | Default | Description |
| :--- | :--- | :--- | :--- |
| id | string \| number | Auto-generated | Optional unique identifier. If triggered again with the same ID, updates the active notification in-place. |
| title | string | Variant Name | Header title text displayed in the compact tab state. |
| description | React.ReactNode | "" | Primary body content displayed in the morph-expanded drawer. |
| type | 'default' \| 'success' \| 'error' \| 'warning' \| 'info' \| 'loading' | 'default' | Color palette and icon preset styling variant. |
| position | 'top-left' \| 'top-center' \| 'top-right' \| 'bottom-left' \| 'bottom-center' \| 'bottom-right' | 'bottom-right' | Screen positioning anchor. |
| duration | number | 4000 | Lifetime in milliseconds. Set to 0 or Infinity to keep persistent. |
| action | GooeyNotiAction | undefined | Interactive CTA button added inside the notification body. |
| pauseOnHover | boolean | true | When true, pauses the auto-dismiss timer whenever the user hovers over the notification. |
| fillColor | string | undefined | Custom background fill color for the SVG morphing container. |
| className | string | undefined | Additional CSS class for the root wrapper. |
Helper Methods
noti.success(title, options)noti.error(title, options)noti.warning(title, options)noti.info(title, options)noti.custom(options)noti.dismiss(id)noti.update(id, options)noti.promise(promise, options)
useNotis()
A custom React hook that returns an array of currently active NotiActive state objects.
🎨 Theme & Customization
The library is designed to automatically adapt to light/dark themes by referencing utility classes. When loaded inside applications utilizing next-themes, the viewport automatically synchronizes with active system resolutions seamlessly.
