Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kayoshi-dev/usetoast
A little vanilla Javascript hook to display Notification. This is an experimental project to learn NPM, Vite as a bundler and TS.
https://github.com/kayoshi-dev/usetoast
toast
Last synced: 25 days ago
JSON representation
A little vanilla Javascript hook to display Notification. This is an experimental project to learn NPM, Vite as a bundler and TS.
- Host: GitHub
- URL: https://github.com/kayoshi-dev/usetoast
- Owner: Kayoshi-dev
- Created: 2022-05-13T12:52:02.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-06-17T19:18:28.000Z (over 2 years ago)
- Last Synced: 2024-04-29T20:45:07.161Z (6 months ago)
- Topics: toast
- Language: TypeScript
- Homepage:
- Size: 196 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
UseToastUnder heavy development!
---
## How to install
npm i @kayoshi-dev/usetoast
## Documentation
The useToast library allow you to display toast messages easily.
To get started, you need to import the useToast function from the library.
import { useToast } from '@kayoshi-dev/usetoast';
Then you need to use the useToast function to access the createToast function, and you can extract that function like that :
const { createToast } = useToast();
This function allow you to create a toast message, it takes a message, a type, an icon and a duration as parameters.
createToast('Hello world', 'success', '', 5000);
For the moment, the type parameter can be one of the following :
- success
- info
- errorYou can give any icon you want to the createToast function.
## Use with SSR
If you want to use the useToast library in an SSR environment, you might need to dynamically import the library :
const useToast = (await import('@kayoshi-dev/usetoast')).default
## Contributing
If you're interested in contributing to the project, feel free to submit a pull request explaining what you're adding to the code.