Documentation Index
Fetch the complete documentation index at: https://mintlify.com/finsweet/attributes/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The Scroll Disable attribute allows you to disable (and re-enable) page scrolling based on various triggers. This is particularly useful for modals, mobile menus, and other overlay interfaces where you want to prevent background scrolling.Attribute Syntax
Elements
Defines how the element controls scrolling:
when-visible- Disables scrolling when the element is visible, enables when hiddenenable- Enables scrolling when clickeddisable- Disables scrolling when clickedtoggle- Toggles scrolling on/off when clickedsmart-nav- For Webflow Navbar components; disables scrolling when nav menu is openpreserve- Applied to elements that should remain scrollable when page scrolling is disabled
Settings
Defines a media query that restricts when an element acts as a trigger. Useful for only disabling scroll on mobile devices.
Defines whether to reserve space for the scrollbar when disabling scroll. Set on the
<script> tag. Prevents layout shift when scrollbar disappears.Defines the overflow type used to disable scrolling:
hidden- Default; hides scrollbarclip- Clips content without scrollbar
Usage Examples
Common Use Cases
Modal Dialogs
Prevent background scrolling when modals are open:Mobile Navigation
Disable scrolling when mobile menu is open, only on mobile devices:Side Drawers
Prevent background scroll when side panels are visible:Fullscreen Search
Disable scroll when fullscreen search overlay is active:Cookie Banners
Force users to interact with cookie consent (use carefully for UX):Element Types Explained
when-visible
Automatically manages scroll state based on element visibility:- Element visible → Scroll disabled
- Element hidden → Scroll enabled
enable / disable
Manual control via click events:- Click → Changes scroll state once
toggle
Toggles scroll state on each click:- First click → Disable scroll
- Second click → Enable scroll
- Third click → Disable scroll
- …
smart-nav
Automatic handling for Webflow Navbar components:- Detects when nav menu opens/closes
- Disables scroll when open
- Re-enables when closed
preserve
Allows specific elements to remain scrollable when page scroll is disabled:- Parent scroll: Disabled
- This element: Still scrollable
Media Query Usage
Common media query values:Webflow Navbar Integration
For Webflow’s navbar component, use thesmart-nav element:
- Navbar open/close state
- Which breakpoint is active
- Whether to disable scroll
Scrollbar Gap
By default, the attribute reserves space for the scrollbar to prevent layout shift: With gap (default):- Content doesn’t shift when scrollbar disappears
- Better user experience
- Recommended for most use cases
- Content may shift when scrollbar disappears
- Useful if you’re handling layout yourself
Technical Details
How It Disables Scroll
The attribute uses the tua-body-scroll-lock library, which:- Prevents touch-based scrolling on mobile
- Prevents mouse wheel scrolling on desktop
- Prevents keyboard scrolling (space, arrow keys)
- Maintains scroll position
- Allows nested scrollable elements
Preserved Elements
Elements withfs-scrolldisable-element="preserve" can still be scrolled using:
- Touch gestures
- Mouse wheel
- Scrollbar dragging
The attribute uses
overflow: hidden (or clip) on the <body> element to disable scrolling. This is the most reliable cross-browser method.