Hide-on-scroll that flows naturally with your scroll speed - no jarring animations
Only 1.1KB โข Zero Animations โข Multiple Elements
Just 1.1KB minified for headers, 1.2KB for footers. 4x smaller than Headroom.js with zero dependencies and maximum performance.
Animate multiple headers, footers, and floating elements simultaneously without conflicts. Traditional sticky or floating modes for maximum flexibility.
No jarring animations or sudden pop-ins. Elements flow naturally with your scroll speed, creating seamless movement that doesn't break focus.
Three precise parameters control natural feel, activation timing, and gap prevention. From pure natural movement to magnetic snapping, perfect for any use case.
Try scrolling in the embedded demos below, or click to open them full-screen
Stripped-down demos focusing on implementation details
๐ Minimal Header ๐ Minimal Footer ๐ Minimal Floating Header ๐ Minimal Floating Footernpm install natural-sticky
<script src="https://cdn.jsdelivr.net/npm/natural-sticky/dist/natural-sticky.top.min.js"></script> <script> document.addEventListener('DOMContentLoaded', () => { const header = document.querySelector('.my-header'); // Default behavior (traditional sticky) window.naturalStickyTop(header); // Floating elements mode window.naturalStickyTop(header, { reserveSpace: false }); // Fine-tune with scrollThreshold and snapEagerness window.naturalStickyTop(header, { snapEagerness: 2.0, scrollThreshold: 10, // Only activate on medium-speed scrolling reserveSpace: true // Traditional sticky (default) }); }); </script>
import { naturalStickyTop, naturalStickyBottom } from 'natural-sticky'; // For headers (traditional sticky by default) const headerInstance = naturalStickyTop(document.querySelector('.header')); // For footers with floating elements mode const footerInstance = naturalStickyBottom(document.querySelector('.footer'), { reserveSpace: false }); // Fine-tune all parameters const customHeader = naturalStickyTop(document.querySelector('.header'), { snapEagerness: 2.0, // More eager snapping to prevent visual gaps scrollThreshold: 15, // Only activate on moderate to fast scrolling reserveSpace: true // Traditional sticky (default) }); // Clean up when needed headerInstance.destroy(); footerInstance.destroy();
Traditional sticky headers use CSS transitions or JavaScript animations that can feel jarring and disconnected from the user's scroll behavior. Natural Sticky takes a different approach:
The secret is in switching between position: sticky
and
position: relative
(or position: fixed
and
position: absolute
for floating elements) at exactly the
right moments, letting the browser's native scrolling handle all the
movement naturally.
The reserveSpace
parameter (default: true) controls how
elements behave:
The snapEagerness
parameter (default: 1.0) lets you
balance between natural movement and gap prevention:
The new scrollThreshold
parameter (default: 0) controls
when the natural scroll-in effect activates based on scroll speed:
Perfect for creating more intentional user interactions. Headers might use lower thresholds (always accessible), while footers might use higher thresholds (only appear during deliberate navigation).
View on GitHub โ