# Scroll Containers Create scrolling containers using the scroll snap features from Tailwind. ## Scroll Snap Implements Tailwind's [Scroll Snap Alignment](https://tailwindcss.com/docs/scroll-snap-align) utility classes. ```html
{ Array.from({ length: 8 }).map((_, i) => ( // Each scrollable card element
{i + 1}
)) }
``` ## Carousels Using Scroll Containers, we can create a fully functional carousel, complete with thumbnail selection. ```html --- const generatedArray = Array.from({ length: 6 }); ---
{ generatedArray.map((_, i: number) => ( {`full-${i}`} )) }
{ generatedArray.map((_, i: number) => ( )) }
``` ## Multi-Column Using Scroll Containers, we can scroll sets of items. ```html --- interface Movie { name: string; imageUrl: string; url: string; } // Data and images via: https://www.themoviedb.org/ { name: 'The Flash', imageUrl: 'https://www.themoviedb.org/t/p/w600_and_h900_bestv2/rktDFPbfHfUbArZ6OOOKsXcv0Bm.jpg', url: 'https://www.themoviedb.org/movie/298618-the-flash', }, { name: 'Guardians of the Galaxy Vol. 3', imageUrl: 'https://www.themoviedb.org/t/p/w600_and_h900_bestv2/r2J02Z2OpNTctfOSN1Ydgii51I3.jpg', url: 'https://www.themoviedb.org/movie/447365-guardians-of-the-galaxy-vol-3', }, { name: 'Black Panther: Wakanda Forever', imageUrl: 'https://www.themoviedb.org/t/p/w600_and_h900_bestv2/sv1xJUazXeYqALzczSZ3O6nkH75.jpg', url: 'https://www.themoviedb.org/movie/505642-black-panther-wakanda-forever', }, { name: 'Avengers: Infinity War', imageUrl: 'https://www.themoviedb.org/t/p/w600_and_h900_bestv2/7WsyChQLEftFiDOVTGkv3hFpyyt.jpg', url: 'https://www.themoviedb.org/movie/299536-avengers-infinity-war', }, { name: 'Spider-Man: No Way Home', imageUrl: 'https://www.themoviedb.org/t/p/w600_and_h900_bestv2/1g0dhYtq4irTY1GPXvft6k4YLjm.jpg', url: 'https://www.themoviedb.org/movie/634649-spider-man-no-way-home', }, { name: 'The Batman', imageUrl: 'https://www.themoviedb.org/t/p/w600_and_h900_bestv2/74xTEgt7R36Fpooo50r9T25onhq.jpg', url: 'https://www.themoviedb.org/movie/414906-the-batman', }, { name: 'Iron Man', imageUrl: 'https://www.themoviedb.org/t/p/w600_and_h900_bestv2/78lPtwv72eTNqFW9COBYI0dWDJa.jpg', url: 'https://www.themoviedb.org/movie/1726-iron-man', }, { name: 'Venom: Let There Be Carnage', imageUrl: 'https://www.themoviedb.org/t/p/w600_and_h900_bestv2/rjkmN1dniUHVYAtwuV3Tji7FsDO.jpg', url: 'https://www.themoviedb.org/movie/580489-venom-let-there-be-carnage', }, { name: 'Deadpool', imageUrl: 'https://www.themoviedb.org/t/p/w600_and_h900_bestv2/3E53WEZJqP6aM84D8CckXx4pIHw.jpg', url: 'https://www.themoviedb.org/movie/293660-deadpool', }, ]; ---
{ movies.map((movie) => ( {movie.name} )) }
``` > Images courtesy of [The Movie Database](https://www.themoviedb.org/) ## API Reference Learn more about Tailwind's utility classes for scroll behavior and scroll snap. | Feature | Description | | ------------------------------------------------------------------- | ------------------------------------------------------------------- | | [scroll-behavior](https://tailwindcss.com/docs/scroll-behavior) | Controls the scroll behavior of an element. | | [scroll-margin](https://tailwindcss.com/docs/scroll-margin) | Controls the scroll offset around items in a snap container. | | [scroll-padding](https://tailwindcss.com/docs/scroll-padding) | Controls an element's scroll offset within a snap container. | | [scroll-snap-align](https://tailwindcss.com/docs/scroll-snap-align) | Controls the scroll snap alignment of an element. | | [scroll-snap-stop](https://tailwindcss.com/docs/scroll-snap-stop) | Controls whether you can skip past possible snap positions. | | [scroll-snap-type](https://tailwindcss.com/docs/scroll-snap-type) | Controls how strictly snap points are enforced in a snap container. |