- Notifications
You must be signed in to change notification settings - Fork4
chrisgo/bootstrap5-toast
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Copied fromhttps://github.com/Script47/Toast and updated to support Bootstrap 5.xhttps://getbootstrap.com/docs/5.0/components/toasts/as a proof of concept (not complete)
- Makes Bootstrap 5.x Toasts easier to use
- Requires jQuery 3.x
- TODO: Placement/Position is hardcoded to top-right
top-0 start-0
- TODO: Rounded square in the
toast-header
similar to Bootstrap documentation - TODO: Image
- TODO: Investigate
delay
, does not seem to be working
Code for Rounded square in Header
<divclass="toast-header"><svgclass="rounded me-2"width="20"height="20"xmlns="http://www.w3.org/2000/svg"preserveAspectRatio="xMidYMid slice"focusable="false"role="img"><rectfill="#007aff"width="100%"height="100%"/></svg> ...</div>
- Only need the JS file, all the CSS is from Bootstrap 5.x
<scriptsrc="src/toast.js"></script>
Modify the global variables to apply specific rules/styles to all your toasts.
$.toastDefaults={position:'top-right',/** top-left/top-right/top-center/bottom-left/bottom-right/bottom-center - Where the toast will show up **/dismissible:true,/** true/false - If you want to show the button to dismiss the toast manually **/stackable:true,/** true/false - If you want the toasts to be stackable **/pauseDelayOnHover:true,/** true/false - If you want to pause the delay of toast when hovering over the toast **/style:{toast:'',/** Classes you want to apply separated my a space to each created toast element (.toast) **/info:'',/** Classes you want to apply separated my a space to modify the "info" type style **/success:'',/** Classes you want to apply separated my a space to modify the "success" type style **/warning:'',/** Classes you want to apply separated my a space to modify the "warning" type style **/error:'',/** Classes you want to apply separated my a space to modify the "error" type style **/}};
A "snack" is a bitesized "toast".
$.snack(type,content,delay)
Note: The final argumentdelay
is omitable. If omitted, the toast will remain forever.
$.toast({type:'info',title:'Notice!',subtitle:'11 mins ago',content:'Hello, world! This is a toast message.',delay:5000,img:{src:'https://via.placeholder.com/20',class:'rounded-0',/** Classes you want to apply separated my a space to modify the image **/alt:'Image'}});
Feel free to contribute in any of the ways outlined:
- Submit issues/pull requests
- Tell us how you're using this plugin inyour project
About
Makes Bootstrap 5.x Toasts easier to use
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
No releases published
Packages0
No packages published