UNPKG

react-toastly

Version:

A beautiful React toast notification library with animations, gradients, sounds, and premium features for free.

126 lines (84 loc) 3.61 kB
# React Toastly A lightweight React toast notification library with sounds and promise support — written in JSX, no TypeScript required. ## Installation ```bash npm install react-toastly ``` or ```bash yarn add react-toastly ``` ## Usage Wrap your app with `ToastlyProvider` and call toast methods from `useToastly` hook. ## ToastlyProvider Provides context for toast management and renders toast UI. ```jsx import { ToastlyProvider } from "react-toastly-jsx"; function App() { return ( <ToastlyProvider> <YourApp /> </ToastlyProvider> ); } ``` ## useToastly Hook Use this hook inside your components to trigger toasts: ```jsx import { useToastly } from "react-toastly-jsx"; function MyComponent() { const toast = useToastly(); return <button onClick={() => toast.success("Hello!")}>Show Toast</button>; } ``` ## Toast Methods - `success(msg)` - `error(msg)` - `warning(msg)` - `info(msg)` - `custom(content)` - JSX content - `promise(promise, {loading, success, error})` - Promise based toasts ## Sound Setup Place sound files in your public folder: - /public/sounds/success.mp3 - /public/sounds/error.mp3 - /public/sounds/warning.mp3 - /public/sounds/info.mp3 ## Example See `Demo.jsx` for a usage example. ## Features | Feature | Description | |-----------------------|-----------------------------------------------------------| | Toast Types | success, error, warning, info, custom | | Promise-based Toasts | Display loading, success, and error states automatically | | Sound Notifications | Plays sound for each toast type | | Easy Setup | Simple provider and hook API | | Customizable | Pass JSX content for custom toasts | | Animations | Slide-in effect on toast appearance | | Auto Dismiss | Toasts auto disappear after duration | ## Documentation Site For detailed usage, examples, and API references, visit our documentation website: [https://react-toastly.dev](https://react-toastly.dev) ## License MIT License © 2025 Jeswin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Developer Support For any issues, feature requests, or questions about React Toastly, please feel free to reach out to the developer team: developer Team GitHub: github.com/jeswin Email: webdevai.00@gmail.com Jeswin and the developer team are happy to assist with bugs, improvements, and any support related to this library.