Interactivity
Scroll Padding
Utilities for controlling an element’s scroll offset within a snap container.
Quick reference
Class | Properties |
---|---|
scroll-p-0 | scroll-padding: 0px; |
scroll-px-0 | scroll-padding-left: 0px; scroll-padding-right: 0px; |
scroll-py-0 | scroll-padding-top: 0px; scroll-padding-bottom: 0px; |
scroll-pt-0 | scroll-padding-top: 0px; |
scroll-pr-0 | scroll-padding-right: 0px; |
scroll-pb-0 | scroll-padding-bottom: 0px; |
scroll-pl-0 | scroll-padding-left: 0px; |
scroll-p-px | scroll-padding: 1px; |
scroll-px-px | scroll-padding-left: 1px; scroll-padding-right: 1px; |
scroll-py-px | scroll-padding-top: 1px; scroll-padding-bottom: 1px; |
scroll-pt-px | scroll-padding-top: 1px; |
scroll-pr-px | scroll-padding-right: 1px; |
scroll-pb-px | scroll-padding-bottom: 1px; |
scroll-pl-px | scroll-padding-left: 1px; |
scroll-p-0.5 | scroll-padding: 0.125rem; |
scroll-px-0.5 | scroll-padding-left: 0.125rem; scroll-padding-right: 0.125rem; |
scroll-py-0.5 | scroll-padding-top: 0.125rem; scroll-padding-bottom: 0.125rem; |
scroll-pt-0.5 | scroll-padding-top: 0.125rem; |
scroll-pr-0.5 | scroll-padding-right: 0.125rem; |
scroll-pb-0.5 | scroll-padding-bottom: 0.125rem; |
scroll-pl-0.5 | scroll-padding-left: 0.125rem; |
scroll-p-1 | scroll-padding: 0.25rem; |
scroll-px-1 | scroll-padding-left: 0.25rem; scroll-padding-right: 0.25rem; |
scroll-py-1 | scroll-padding-top: 0.25rem; scroll-padding-bottom: 0.25rem; |
scroll-pt-1 | scroll-padding-top: 0.25rem; |
scroll-pr-1 | scroll-padding-right: 0.25rem; |
scroll-pb-1 | scroll-padding-bottom: 0.25rem; |
scroll-pl-1 | scroll-padding-left: 0.25rem; |
scroll-p-1.5 | scroll-padding: 0.375rem; |
scroll-px-1.5 | scroll-padding-left: 0.375rem; scroll-padding-right: 0.375rem; |
scroll-py-1.5 | scroll-padding-top: 0.375rem; scroll-padding-bottom: 0.375rem; |
scroll-pt-1.5 | scroll-padding-top: 0.375rem; |
scroll-pr-1.5 | scroll-padding-right: 0.375rem; |
scroll-pb-1.5 | scroll-padding-bottom: 0.375rem; |
scroll-pl-1.5 | scroll-padding-left: 0.375rem; |
scroll-p-2 | scroll-padding: 0.5rem; |
scroll-px-2 | scroll-padding-left: 0.5rem; scroll-padding-right: 0.5rem; |
scroll-py-2 | scroll-padding-top: 0.5rem; scroll-padding-bottom: 0.5rem; |
scroll-pt-2 | scroll-padding-top: 0.5rem; |
scroll-pr-2 | scroll-padding-right: 0.5rem; |
scroll-pb-2 | scroll-padding-bottom: 0.5rem; |
scroll-pl-2 | scroll-padding-left: 0.5rem; |
scroll-p-2.5 | scroll-padding: 0.625rem; |
scroll-px-2.5 | scroll-padding-left: 0.625rem; scroll-padding-right: 0.625rem; |
scroll-py-2.5 | scroll-padding-top: 0.625rem; scroll-padding-bottom: 0.625rem; |
scroll-pt-2.5 | scroll-padding-top: 0.625rem; |
scroll-pr-2.5 | scroll-padding-right: 0.625rem; |
scroll-pb-2.5 | scroll-padding-bottom: 0.625rem; |
scroll-pl-2.5 | scroll-padding-left: 0.625rem; |
scroll-p-3 | scroll-padding: 0.75rem; |
scroll-px-3 | scroll-padding-left: 0.75rem; scroll-padding-right: 0.75rem; |
scroll-py-3 | scroll-padding-top: 0.75rem; scroll-padding-bottom: 0.75rem; |
scroll-pt-3 | scroll-padding-top: 0.75rem; |
scroll-pr-3 | scroll-padding-right: 0.75rem; |
scroll-pb-3 | scroll-padding-bottom: 0.75rem; |
scroll-pl-3 | scroll-padding-left: 0.75rem; |
scroll-p-3.5 | scroll-padding: 0.875rem; |
scroll-px-3.5 | scroll-padding-left: 0.875rem; scroll-padding-right: 0.875rem; |
scroll-py-3.5 | scroll-padding-top: 0.875rem; scroll-padding-bottom: 0.875rem; |
scroll-pt-3.5 | scroll-padding-top: 0.875rem; |
scroll-pr-3.5 | scroll-padding-right: 0.875rem; |
scroll-pb-3.5 | scroll-padding-bottom: 0.875rem; |
scroll-pl-3.5 | scroll-padding-left: 0.875rem; |
scroll-p-4 | scroll-padding: 1rem; |
scroll-px-4 | scroll-padding-left: 1rem; scroll-padding-right: 1rem; |
scroll-py-4 | scroll-padding-top: 1rem; scroll-padding-bottom: 1rem; |
scroll-pt-4 | scroll-padding-top: 1rem; |
scroll-pr-4 | scroll-padding-right: 1rem; |
scroll-pb-4 | scroll-padding-bottom: 1rem; |
scroll-pl-4 | scroll-padding-left: 1rem; |
scroll-p-5 | scroll-padding: 1.25rem; |
scroll-px-5 | scroll-padding-left: 1.25rem; scroll-padding-right: 1.25rem; |
scroll-py-5 | scroll-padding-top: 1.25rem; scroll-padding-bottom: 1.25rem; |
scroll-pt-5 | scroll-padding-top: 1.25rem; |
scroll-pr-5 | scroll-padding-right: 1.25rem; |
scroll-pb-5 | scroll-padding-bottom: 1.25rem; |
scroll-pl-5 | scroll-padding-left: 1.25rem; |
scroll-p-6 | scroll-padding: 1.5rem; |
scroll-px-6 | scroll-padding-left: 1.5rem; scroll-padding-right: 1.5rem; |
scroll-py-6 | scroll-padding-top: 1.5rem; scroll-padding-bottom: 1.5rem; |
scroll-pt-6 | scroll-padding-top: 1.5rem; |
scroll-pr-6 | scroll-padding-right: 1.5rem; |
scroll-pb-6 | scroll-padding-bottom: 1.5rem; |
scroll-pl-6 | scroll-padding-left: 1.5rem; |
scroll-p-7 | scroll-padding: 1.75rem; |
scroll-px-7 | scroll-padding-left: 1.75rem; scroll-padding-right: 1.75rem; |
scroll-py-7 | scroll-padding-top: 1.75rem; scroll-padding-bottom: 1.75rem; |
scroll-pt-7 | scroll-padding-top: 1.75rem; |
scroll-pr-7 | scroll-padding-right: 1.75rem; |
scroll-pb-7 | scroll-padding-bottom: 1.75rem; |
scroll-pl-7 | scroll-padding-left: 1.75rem; |
scroll-p-8 | scroll-padding: 2rem; |
scroll-px-8 | scroll-padding-left: 2rem; scroll-padding-right: 2rem; |
scroll-py-8 | scroll-padding-top: 2rem; scroll-padding-bottom: 2rem; |
scroll-pt-8 | scroll-padding-top: 2rem; |
scroll-pr-8 | scroll-padding-right: 2rem; |
scroll-pb-8 | scroll-padding-bottom: 2rem; |
scroll-pl-8 | scroll-padding-left: 2rem; |
scroll-p-9 | scroll-padding: 2.25rem; |
scroll-px-9 | scroll-padding-left: 2.25rem; scroll-padding-right: 2.25rem; |
scroll-py-9 | scroll-padding-top: 2.25rem; scroll-padding-bottom: 2.25rem; |
scroll-pt-9 | scroll-padding-top: 2.25rem; |
scroll-pr-9 | scroll-padding-right: 2.25rem; |
scroll-pb-9 | scroll-padding-bottom: 2.25rem; |
scroll-pl-9 | scroll-padding-left: 2.25rem; |
scroll-p-10 | scroll-padding: 2.5rem; |
scroll-px-10 | scroll-padding-left: 2.5rem; scroll-padding-right: 2.5rem; |
scroll-py-10 | scroll-padding-top: 2.5rem; scroll-padding-bottom: 2.5rem; |
scroll-pt-10 | scroll-padding-top: 2.5rem; |
scroll-pr-10 | scroll-padding-right: 2.5rem; |
scroll-pb-10 | scroll-padding-bottom: 2.5rem; |
scroll-pl-10 | scroll-padding-left: 2.5rem; |
scroll-p-11 | scroll-padding: 2.75rem; |
scroll-px-11 | scroll-padding-left: 2.75rem; scroll-padding-right: 2.75rem; |
scroll-py-11 | scroll-padding-top: 2.75rem; scroll-padding-bottom: 2.75rem; |
scroll-pt-11 | scroll-padding-top: 2.75rem; |
scroll-pr-11 | scroll-padding-right: 2.75rem; |
scroll-pb-11 | scroll-padding-bottom: 2.75rem; |
scroll-pl-11 | scroll-padding-left: 2.75rem; |
scroll-p-12 | scroll-padding: 3rem; |
scroll-px-12 | scroll-padding-left: 3rem; scroll-padding-right: 3rem; |
scroll-py-12 | scroll-padding-top: 3rem; scroll-padding-bottom: 3rem; |
scroll-pt-12 | scroll-padding-top: 3rem; |
scroll-pr-12 | scroll-padding-right: 3rem; |
scroll-pb-12 | scroll-padding-bottom: 3rem; |
scroll-pl-12 | scroll-padding-left: 3rem; |
scroll-p-14 | scroll-padding: 3.5rem; |
scroll-px-14 | scroll-padding-left: 3.5rem; scroll-padding-right: 3.5rem; |
scroll-py-14 | scroll-padding-top: 3.5rem; scroll-padding-bottom: 3.5rem; |
scroll-pt-14 | scroll-padding-top: 3.5rem; |
scroll-pr-14 | scroll-padding-right: 3.5rem; |
scroll-pb-14 | scroll-padding-bottom: 3.5rem; |
scroll-pl-14 | scroll-padding-left: 3.5rem; |
scroll-p-16 | scroll-padding: 4rem; |
scroll-px-16 | scroll-padding-left: 4rem; scroll-padding-right: 4rem; |
scroll-py-16 | scroll-padding-top: 4rem; scroll-padding-bottom: 4rem; |
scroll-pt-16 | scroll-padding-top: 4rem; |
scroll-pr-16 | scroll-padding-right: 4rem; |
scroll-pb-16 | scroll-padding-bottom: 4rem; |
scroll-pl-16 | scroll-padding-left: 4rem; |
scroll-p-20 | scroll-padding: 5rem; |
scroll-px-20 | scroll-padding-left: 5rem; scroll-padding-right: 5rem; |
scroll-py-20 | scroll-padding-top: 5rem; scroll-padding-bottom: 5rem; |
scroll-pt-20 | scroll-padding-top: 5rem; |
scroll-pr-20 | scroll-padding-right: 5rem; |
scroll-pb-20 | scroll-padding-bottom: 5rem; |
scroll-pl-20 | scroll-padding-left: 5rem; |
scroll-p-24 | scroll-padding: 6rem; |
scroll-px-24 | scroll-padding-left: 6rem; scroll-padding-right: 6rem; |
scroll-py-24 | scroll-padding-top: 6rem; scroll-padding-bottom: 6rem; |
scroll-pt-24 | scroll-padding-top: 6rem; |
scroll-pr-24 | scroll-padding-right: 6rem; |
scroll-pb-24 | scroll-padding-bottom: 6rem; |
scroll-pl-24 | scroll-padding-left: 6rem; |
scroll-p-28 | scroll-padding: 7rem; |
scroll-px-28 | scroll-padding-left: 7rem; scroll-padding-right: 7rem; |
scroll-py-28 | scroll-padding-top: 7rem; scroll-padding-bottom: 7rem; |
scroll-pt-28 | scroll-padding-top: 7rem; |
scroll-pr-28 | scroll-padding-right: 7rem; |
scroll-pb-28 | scroll-padding-bottom: 7rem; |
scroll-pl-28 | scroll-padding-left: 7rem; |
scroll-p-32 | scroll-padding: 8rem; |
scroll-px-32 | scroll-padding-left: 8rem; scroll-padding-right: 8rem; |
scroll-py-32 | scroll-padding-top: 8rem; scroll-padding-bottom: 8rem; |
scroll-pt-32 | scroll-padding-top: 8rem; |
scroll-pr-32 | scroll-padding-right: 8rem; |
scroll-pb-32 | scroll-padding-bottom: 8rem; |
scroll-pl-32 | scroll-padding-left: 8rem; |
scroll-p-36 | scroll-padding: 9rem; |
scroll-px-36 | scroll-padding-left: 9rem; scroll-padding-right: 9rem; |
scroll-py-36 | scroll-padding-top: 9rem; scroll-padding-bottom: 9rem; |
scroll-pt-36 | scroll-padding-top: 9rem; |
scroll-pr-36 | scroll-padding-right: 9rem; |
scroll-pb-36 | scroll-padding-bottom: 9rem; |
scroll-pl-36 | scroll-padding-left: 9rem; |
scroll-p-40 | scroll-padding: 10rem; |
scroll-px-40 | scroll-padding-left: 10rem; scroll-padding-right: 10rem; |
scroll-py-40 | scroll-padding-top: 10rem; scroll-padding-bottom: 10rem; |
scroll-pt-40 | scroll-padding-top: 10rem; |
scroll-pr-40 | scroll-padding-right: 10rem; |
scroll-pb-40 | scroll-padding-bottom: 10rem; |
scroll-pl-40 | scroll-padding-left: 10rem; |
scroll-p-44 | scroll-padding: 11rem; |
scroll-px-44 | scroll-padding-left: 11rem; scroll-padding-right: 11rem; |
scroll-py-44 | scroll-padding-top: 11rem; scroll-padding-bottom: 11rem; |
scroll-pt-44 | scroll-padding-top: 11rem; |
scroll-pr-44 | scroll-padding-right: 11rem; |
scroll-pb-44 | scroll-padding-bottom: 11rem; |
scroll-pl-44 | scroll-padding-left: 11rem; |
scroll-p-48 | scroll-padding: 12rem; |
scroll-px-48 | scroll-padding-left: 12rem; scroll-padding-right: 12rem; |
scroll-py-48 | scroll-padding-top: 12rem; scroll-padding-bottom: 12rem; |
scroll-pt-48 | scroll-padding-top: 12rem; |
scroll-pr-48 | scroll-padding-right: 12rem; |
scroll-pb-48 | scroll-padding-bottom: 12rem; |
scroll-pl-48 | scroll-padding-left: 12rem; |
scroll-p-52 | scroll-padding: 13rem; |
scroll-px-52 | scroll-padding-left: 13rem; scroll-padding-right: 13rem; |
scroll-py-52 | scroll-padding-top: 13rem; scroll-padding-bottom: 13rem; |
scroll-pt-52 | scroll-padding-top: 13rem; |
scroll-pr-52 | scroll-padding-right: 13rem; |
scroll-pb-52 | scroll-padding-bottom: 13rem; |
scroll-pl-52 | scroll-padding-left: 13rem; |
scroll-p-56 | scroll-padding: 14rem; |
scroll-px-56 | scroll-padding-left: 14rem; scroll-padding-right: 14rem; |
scroll-py-56 | scroll-padding-top: 14rem; scroll-padding-bottom: 14rem; |
scroll-pt-56 | scroll-padding-top: 14rem; |
scroll-pr-56 | scroll-padding-right: 14rem; |
scroll-pb-56 | scroll-padding-bottom: 14rem; |
scroll-pl-56 | scroll-padding-left: 14rem; |
scroll-p-60 | scroll-padding: 15rem; |
scroll-px-60 | scroll-padding-left: 15rem; scroll-padding-right: 15rem; |
scroll-py-60 | scroll-padding-top: 15rem; scroll-padding-bottom: 15rem; |
scroll-pt-60 | scroll-padding-top: 15rem; |
scroll-pr-60 | scroll-padding-right: 15rem; |
scroll-pb-60 | scroll-padding-bottom: 15rem; |
scroll-pl-60 | scroll-padding-left: 15rem; |
scroll-p-64 | scroll-padding: 16rem; |
scroll-px-64 | scroll-padding-left: 16rem; scroll-padding-right: 16rem; |
scroll-py-64 | scroll-padding-top: 16rem; scroll-padding-bottom: 16rem; |
scroll-pt-64 | scroll-padding-top: 16rem; |
scroll-pr-64 | scroll-padding-right: 16rem; |
scroll-pb-64 | scroll-padding-bottom: 16rem; |
scroll-pl-64 | scroll-padding-left: 16rem; |
scroll-p-72 | scroll-padding: 18rem; |
scroll-px-72 | scroll-padding-left: 18rem; scroll-padding-right: 18rem; |
scroll-py-72 | scroll-padding-top: 18rem; scroll-padding-bottom: 18rem; |
scroll-pt-72 | scroll-padding-top: 18rem; |
scroll-pr-72 | scroll-padding-right: 18rem; |
scroll-pb-72 | scroll-padding-bottom: 18rem; |
scroll-pl-72 | scroll-padding-left: 18rem; |
scroll-p-80 | scroll-padding: 20rem; |
scroll-px-80 | scroll-padding-left: 20rem; scroll-padding-right: 20rem; |
scroll-py-80 | scroll-padding-top: 20rem; scroll-padding-bottom: 20rem; |
scroll-pt-80 | scroll-padding-top: 20rem; |
scroll-pr-80 | scroll-padding-right: 20rem; |
scroll-pb-80 | scroll-padding-bottom: 20rem; |
scroll-pl-80 | scroll-padding-left: 20rem; |
scroll-p-96 | scroll-padding: 24rem; |
scroll-px-96 | scroll-padding-left: 24rem; scroll-padding-right: 24rem; |
scroll-py-96 | scroll-padding-top: 24rem; scroll-padding-bottom: 24rem; |
scroll-pt-96 | scroll-padding-top: 24rem; |
scroll-pr-96 | scroll-padding-right: 24rem; |
scroll-pb-96 | scroll-padding-bottom: 24rem; |
scroll-pl-96 | scroll-padding-left: 24rem; |
Show all classes
Basic usage
Setting the scroll padding
Use the scroll-p{side}-{size}
utilities to set the scroll offset of an element within a snap container.
Scroll in the grid of images to see the expected behaviour
<div class="scroll-pl-6 snap-x ...">
<div class="snap-start ...">
<img src="https://images.unsplash.com/photo-1604999565976-8913ad2ddb7c?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=320&h=160&q=80" />
</div>
<div class="snap-start ...">
<img src="https://images.unsplash.com/photo-1540206351-d6465b3ac5c1?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=320&h=160&q=80" />
</div>
<div class="snap-start ...">
<img src="https://images.unsplash.com/photo-1622890806166-111d7f6c7c97?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=320&h=160&q=80" />
</div>
<div class="snap-start ...">
<img src="https://images.unsplash.com/photo-1590523277543-a94d2e4eb00b?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=320&h=160&q=80" />
</div>
<div class="snap-start ...">
<img src="https://images.unsplash.com/photo-1575424909138-46b05e5919ec?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=320&h=160&q=80" />
</div>
</div>
Applying conditionally
Hover, focus, and other states
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:scroll-p-0
to only apply the scroll-p-0
utility on hover.
<div class="scroll-p-8 hover:scroll-p-0">
<!-- ... -->
</div>
For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.
Breakpoints and media queries
You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:scroll-p-0
to apply the scroll-p-0
utility at only medium screen sizes and above.
<div class="scroll-p-8 md:scroll-p-0">
<!-- ... -->
</div>
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.
Using custom values
Customizing your theme
By default, Tailwind’s scroll padding scale uses the default spacing scale. You can customize your spacing scale by editing theme.spacing
or theme.extend.spacing
in your tailwind.config.js
file.
tailwind.config.js
module.exports = { theme: { extend: { spacing: { '96': '24rem', } } }}
Alternatively, you can customize just the scroll padding scale by editing theme.scrollPadding
or theme.extend.scrollPadding
in your tailwind.config.js
file.
tailwind.config.js
module.exports = { theme: { extend: { scrollPadding: { '96': '24rem', }, } }}
Learn more about customizing the default theme in the theme customization documentation.
Arbitrary values
If you need to use a one-off scroll-padding
value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value.
<div class="scroll-p-[24rem]">
<!-- ... -->
</div>
Learn more about arbitrary value support in the arbitrary values documentation.