tmt-toast
v1.0.1
Published
A simple toast notification library
Readme
Toast Library Documentation
This guide will help you understand how to install, configure, and use the Toast Library in your React projects. The Toast Library is a lightweight notification system that supports different types of messages such as success, error, and informational toasts with shadow effects and icons.
Introduction
The Toast Library provides an easy-to-use solution for adding dynamic notifications to your React applications. Notifications are displayed with appropriate icons and styled for better user experience. The library supports:
- Success messages with a green tick icon.
- Error messages with a red cross icon.
- Informational messages with a blue info icon.
Installation
To get started, you need to install the Toast Library via npm. Run the following command in your project directory to install the library:
- Ensure you have a React project set up using tools like Vite or Create React App.
- Run the installation command for the Toast Library from npm.
Setup
Once installed, you need to configure your application to use the Toast Library. This involves wrapping your application's root component with the ToastProvider. The ToastProvider is responsible for managing the notifications and displaying them when triggered.
Add the ToastProvider to the highest level of your React component tree, typically in the main entry point of your application.
Using the Library
To display notifications, the library provides a custom hook called useToast. This hook allows you to trigger toasts from any component in your application. Follow these steps to use the toast functionality:
- Import the
useToasthook into your desired component. - Call the
addToastfunction from the hook, passing the message and type of notification you want to display. - Use predefined types like
success,error, orinfoto style the notification appropriately.
Features
- Success Toast: Displays a green tick icon with the message for positive feedback or confirmation.
- Error Toast: Displays a red cross icon with the message for error or failure.
- Info Toast: Displays a blue info icon with the message for general information.
Toasts automatically disappear after a few seconds and include a subtle shadow for visual enhancement.
Customizing the Appearance
The Toast Library uses default styles for icons and shadows. You can override these styles by customizing the CSS in your project. Update the container's position, colors, or animation effects as per your application design.
Publishing Updates
If you make any changes to the Toast Library or extend its features, you can update it for your team or the public. Follow these steps:
- Build the library using your build toolchain.
- Publish the changes to npm using your npm account.
Support
For questions or issues with the Toast Library, please raise a concern on the official repository or reach out to the maintainer's email provided during the installation process.
By following this guide, you’ll be able to integrate and use the Toast Library effectively in your React applications. Enjoy building dynamic and user-friendly notifications for your project!
