Adding a smart health reminder toast notification on your website is one of the best ways to improve user experience and help users avoid long screen sessions. Several modern websites already use this reminder system to suggest actions like drink water, take a break or reduce continuous screen time. These small reminders provide users with a more user-friendly and better browsing experience.
In this guide, you will learn how to add a smart reminder toast notification to your website just using pure CSS and JavaScript. It doesn't rely on any external libraries, so everything will remain lightweight and easy to integrate. The reminder displays at certain time intervals with smooth animations. It reminds users to drink water, take a break and go to bed at a specific time.
Whether you are building a blog, video streaming website, productivity website or any other type of website, it will suit any type of website. This is not only a unique feature for your website but also improves user interaction on your website. So without wasting much time, let's check how this smart health reminder works and how to implement it on your website.
Table of Contents
Features of This Reminder System
- Uses pure CSS and JavaScript
- Lightweight code
- Responsive design
- Automatic reminder
- Smooth animation
- Modern UI
- Dark mode support
How to Add Smart Health Reminder to Your Website
- Go to your webpage HTML file (example: index.html). If you are using Blogger, go to your Blogger dashboard, then click the "Theme" option, then click the drop-down menu next to the "Customise" button, then click the "Edit HTML" option.
- Find the
</head>tag, then add the following CSS just above it and wrap it inside<style></style>. If you are using Blogger, find]]></b:skin>, then paste the CSS just above it. - Find the
</body>tag, paste the following code just above it - 12 = minutes
- 60 = seconds in 1 minute
- 1000 = milliseconds in 1 second
- 5*60*1000 = 5 minutes
- 10*60*1000 = 10 minutes
- 30*60*1000 = 30 minutes
- 60*60*1000 = 1 hour
- Now save the HTML
Adding CSS to the Webpage
/* Smart Health Reminder Toast (www.coshix.in) */.hToast{position:fixed;left:24px;bottom:24px;z-index:999;pointer-events:none}.hToast span{position:relative;display:inline-flex;align-items:center;text-align:left;justify-content:flex-start;gap:8px;background:#323232;color:rgba(255,255,255,.92);font-size:14px;font-family:inherit;line-height:1.5;border-radius:10px;padding:14px 18px;box-shadow:0 10px 40px rgba(149,157,165,.25);opacity:0;transform:translateY(100px);transition:all .25s cubic-bezier(.16,1,.3,1);animation:slideinwards 2.8s cubic-bezier(.16,1,.3,1) forwards;-webkit-animation:slideinwards 2.8s cubic-bezier(.16,1,.3,1) forwards;max-width:320px;backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px)}@media screen and (max-width:500px){.hToast{left:16px;right:16px;bottom:16px}.hToast span{font-size:13px;max-width:none}}@keyframes slideinwards{0%{opacity:0;transform:translateY(100px)}15%,85%{opacity:1;transform:translateY(0)}100%{opacity:0;transform:translateY(100px);visibility:hidden}}@-webkit-keyframes slideinwards{0%{opacity:0;-webkit-transform:translateY(100px)}15%,85%{opacity:1;-webkit-transform:translateY(0)}100%{opacity:0;-webkit-transform:translateY(100px);visibility:hidden}}
/* Dark mode (Remove if not using) */.dark-mode .hToast span{box-shadow:0 10px 40px rgba(0,0,0,.2)}
Adding JavaScript to the Webpage
<!--[ Smart Health Reminder Toast (www.coshix.in) ]-->
<div class='hToast' id='hToast'/>
<script>/*<![CDATA[*//* Smart Health Reminder JS (www.coshix.in) */const hToast=(t,i="☕")=>{const s=document.createElement("span");s.innerHTML=`${i} ${t}`,document.getElementById("hToast").appendChild(s),setTimeout(()=>s.remove(),5500)},h=new Date().getHours();(h>=23||h<5)&&setTimeout(()=>hToast("It's getting late. Sleep is important for your health.","🌙"),2000),setTimeout(()=>hToast("You've been reading for a while. Take a short break and relax your eyes.","☕"),15*60*1000),document.addEventListener("visibilitychange",()=>{"visible"===document.visibilityState&&(clearTimeout(window.__rt),window.__rt=setTimeout(()=>hToast("Still reading? Stand up, stretch a little and drink water.","💧"),12*60*1000))});/*]]>*/</script>
Explanation:
How This Smart Reminder Works
FAQ (Frequently Asked Questions)
Does this reminder affect website performance?
No, this smart health reminder uses lightweight CSS and JavaScript
Does this work in Blogger?
Yes, this smart health reminder works perfectly on Blogger websites
Can I change the reminder timing?
Yes, you can easily customize the timing values inside the JavaScript code.
Will this work on all modern browsers?
Yes, the reminder works on most modern browsers, including Chrome, Edge and Firefox.