Skip to content

✨ Simple (simple as calling a function!) ultra lightweight (1.6kb!) toast notification library built with tailwind css (🥳).

License

Notifications You must be signed in to change notification settings

itaypanda/SimpleToast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

✨ SimpleToast

LicenseMIT CodeSize

Simple toast notification library with Tailwind CSS.

This means TailwindCSS is required! for this to work "out of the box"

⤵️ Installation

Simply include the SimpleToast.js or SimpleToast.min.js file.

Or, you can also link it via JsDelivr:

<script src="https://cdn.jsdelivr.net/gh/itaypanda/simpletoast@master/SimpleToast.min.js"></script>

📝 Change Log

  • August 25th - rewrote some of the code and made it easier to customize, also code is now smaller. - #1

  • November 2nd - added a JsDelivr link, updated a usage instruction renamed some files to demo, updated and made README a little nicer.

  • November 5th - added live demo github pages site.

⚙️ Config

No configuration is required unless you count the init and the toast itself.

🔥 Usage

// Init the library onto the page, can be skipped if you add:
// <div id="alertBox" class="fixed bottom-0 right-0 z-[9999]"></div>
// Anywhere in the page, recommended at the top or bottom
toastInit();

// Example info toast:

toast('Title', 'Message', toastStyles.info);

// Example warn toast:

toast('Title', 'Message', toastStyles.warn);

// Example error toast:

toast('Title', 'Message', toastStyles.error);

// Example success toast:

toast('Title', 'Message', toastStyles.success);


// Example toast with set fade time 10 seconds instead of the default (7.5 seconds):

toast('Title', 'Message', toastStyles.info, 10);

🔧 Adding custom styles

// Defining the style
const toastStyles = {
  // ...
  customStyle: {
    color: "blue", // Tailwind CSS color. Ex: [#ffffff].
    icon: "<svg></svg>" // Doesn't have to be an svg.
  },
}

// Using it
toast('Title', 'Message', toastStyles.customStyle);

Recommended svg/img size: 21x21

💻 Demo

LIVE DEMO: itaypanda.github.io

You can open the demo.html file to view a demo page of the library:

demonstration

👋 Contact/Contribute

Open an issue and I'll answer as soon as I'm available.

Feel free to contribute :D

Feel free to open an issue if you find any, or if you want to add a feature!

⭐ Star History

Star History Chart

📃 License

This project is licensed under the MIT license.

Copyright (c) 2023 itaypanda

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.

💙 Thanks

Thanks to Tailwind CSS / Tailwind Labs, Inc.

https://github.com/tailwindlabs/tailwindcss/blob/master/LICENSE

https://github.com/tailwindlabs/tailwindcs

https://tailwindcss.com/

Thanks to system UIcons

https://github.com/CoreyGinnivan/system-uicons/blob/main/LICENSE

https://github.com/CoreyGinnivan/system-uicons

https://www.systemuicons.com/

About

✨ Simple (simple as calling a function!) ultra lightweight (1.6kb!) toast notification library built with tailwind css (🥳).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published