Utilities & Responsive
Utilities, container queries, responsive shapes and animated borders.
Updated
Which small CSS and JavaScript utilities does a modern website need?
Utilities are small, reusable pieces for everyday needs: a scroll progress bar, a back-to-top button, a theme toggle, copy to clipboard, share and rating buttons, countdowns. They sit next to modern responsive techniques on this page: container queries, fluid shapes and animated gradient borders built with @property.
How to choose, performance and accessibility
- Add a Scroll Progress Bar to long articles, Back to Top on long pages, a Theme Toggle that remembers the choice and follows
prefers-color-scheme, and Copy to Clipboard next to code or promo codes. - Use the Clipboard API rather than the deprecated
execCommand, give icon-only buttons an accessible name, and debounce scroll and resize handlers. - Scroll Progress Bar, Adaptive Card and Gradient Border Spin are free with their full code; the other utilities come with Premium.
Scroll this content to see the progress bar in action. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Sed ut perspiciatis unde omnis iste natus error sit voluptatem.
Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.
Scroll Progress Bar
Reading progress indicator with animated gradient at the top of the content.
View source code
<div class="demo-preview">
<div class="scroll-progress-container">
<div class="scroll-progress-bar" id="scrollProgressBar"></div>
<div class="scroll-progress-content" id="scrollContent">
<p>Scroll this content to see the progress bar in action. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
<p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit.</p>
<p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Sed ut perspiciatis unde omnis iste natus error sit voluptatem.</p>
<p>Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.</p>
</div>
</div>
</div>.demo-preview,
.demo-preview *,
.demo-preview *::before,
.demo-preview *::after {
box-sizing: border-box
}
.demo-preview {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 250px;
overflow: hidden;
position: relative;
background: rgb(26, 26, 36);
color: rgb(255, 255, 255);
font-family: sans-serif;
}
.scroll-progress-container {
width: 100%;
height: 100px;
background: #1a1a2e;
border-radius: 12px;
position: relative;
overflow: hidden;
}
.scroll-progress-bar {
position: absolute;
top: 0;
left: 0;
height: 4px;
width: 0%;
background: linear-gradient(90deg, #6366f1, #8b5cf6, #d946ef);
transition: width 0.1s ease-out;
}
.scroll-progress-content {
padding: 20px;
height: 100%;
overflow-y: auto;
color: rgba(255, 255, 255, 0.7);
font-size: 0.85rem;
line-height: 1.6;
}(function() {
const scrollProgressBar = document.getElementById('scrollProgressBar');
if (scrollContent && scrollProgressBar) {
scrollContent.addEventListener('scroll', function() {
const scrollTop = scrollContent.scrollTop;
const scrollHeight = scrollContent.scrollHeight - scrollContent.clientHeight;
const progress = (scrollTop / scrollHeight) * 100;
scrollProgressBar.style.width = progress + '%';
});
}
})();Back to Top Button
Animated button that appears on scroll with bounce effect.
Theme Toggle
Theme toggle with fluid sun/moon animation.
Countdown Timer
Flip-clock style countdown with flip animation.
Copy to Clipboard
Copy button with animated confirmation and visual feedback.
Rating Stars
Rating system with animated stars and fill effect.
Like / Heart Button
Heart button with heartbeat animation and particle explosion.
Bookmark Toggle
Bookmark icon with elastic save animation.
Notification Badge
Notification badge with pulse, bounce and shake animations.