Horizontal scrolling container with snap points. Perfect for carousels, image galleries, and card sliders.
Overview
A reel lays its children out in one horizontal row that scrolls when it overflows. Items scroll with proximity scroll snap: the reel settles on an item edge when you stop near one, without trapping you mid-item when items are wider than the view. The scrollbar is hidden by default, the edges can fade to hint at more content, and everything is logical, so the reel starts at the right in a right-to-left page.
A reel is a scroll container. When its items hold no links or buttons, give it a name and tabindex="0" so keyboard users can reach and scroll it; every example on this page does. See Accessibility.
Element and attribute forms
The same rules apply to <layout-reel> and to data-layout="reel" on any element, with the same data-layout-* modifiers. Both are below with identical settings.
1234567891011
<layout-reel data-layout-item-width="s" role="region" aria-label="Featured items" tabindex="0"> <layout-card>...</layout-card> <layout-card>...</layout-card></layout-reel> <section data-layout="reel" data-layout-item-width="s" aria-label="Featured items" tabindex="0"> <layout-card>...</layout-card> <layout-card>...</layout-card></section>
Which to choose: use the attribute form when a semantic element is already the scroller: a <section> (a region landmark once named), a list (<ul data-layout="reel" role="list">), or a component such as <card-list data-layout="reel">. Use <layout-reel> when there is no such element, and add role="region" yourself. In the attribute form, main, article, section and aside are also container-query containers, which the element is not. See data-layout for the full comparison.
Attributes
| Attribute |
Values |
Default |
Applies to |
Description |
data-layout-item-width |
auto, s, m, l, xl, full |
auto |
both |
Item width: auto (content), s / m / l / xl (15 / 20 / 25 / 30rem), or full (100%, snapping to the centre). |
data-layout-gap |
none, 3xs, 2xs, xs, s, m, l, xl, 2xl, 3xl |
m |
both |
Gap between items, on the shared size scale. |
data-layout-padding |
none, s, m, l |
s |
both |
Padding on all sides (the block padding leaves room for focus rings and shadows); the same value is the inline scroll padding, so snapped items align with the padded edge. |
data-layout-align |
start, center, end, stretch |
stretch |
both |
Cross-axis alignment of items. |
data-layout-scrollbar |
(boolean) |
— |
both |
Show a thin scrollbar. Hidden by default, except under forced colours and on touch-only devices (hover: none), where it always shows. |
data-scroll-hint |
(bare), start |
— |
both |
Fade the edges to hint at overflow (logical: mirrored in RTL). start: only the end edge ever fades. Fade size: --scroll-hint-size (2rem). |
Child attributes
| Attribute | On | Description |
data-container |
main, article, section, aside |
Opt a semantic child back into container queries. The reel removes container-type from such children so they size to their content (or to data-layout-item-width). |
Examples
Basic usage
The demo at the top of the page:
1234567
<section data-layout="reel" data-layout-gap="m" data-layout-item-width="m" aria-label="Example items" tabindex="0"> <layout-card data-variant="outlined" data-padding="m">Item 1</layout-card> <layout-card data-variant="outlined" data-padding="m">Item 2</layout-card> <layout-card data-variant="outlined" data-padding="m">Item 3</layout-card> <layout-card data-variant="outlined" data-padding="m">Item 4</layout-card> <layout-card data-variant="outlined" data-padding="m">Item 5</layout-card></section>
Item widths
The data-layout-item-width attribute gives every item the same width.
1234567891011121314
<section data-layout="reel" data-layout-gap="s" data-layout-item-width="s" aria-label="Small items" tabindex="0">...</section> <section data-layout="reel" data-layout-gap="m" data-layout-item-width="m" aria-label="Medium items" tabindex="0">...</section> <section data-layout="reel" data-layout-gap="m" data-layout-item-width="l" aria-label="Large items" tabindex="0">...</section> <section data-layout="reel" data-layout-gap="m" data-layout-item-width="xl" aria-label="Extra-large items" tabindex="0">...</section> <section data-layout="reel" data-layout-gap="m" data-layout-item-width="full" aria-label="Full-width slides" tabindex="0">...</section>
Gap
The data-layout-gap attribute controls spacing between items.
123
<section data-layout="reel" data-layout-gap="xs" data-layout-item-width="s" aria-label="Extra-small gap example" tabindex="0">...</section> <section data-layout="reel" data-layout-gap="xl" data-layout-item-width="s" aria-label="Extra-large gap example" tabindex="0">...</section>
Padding and alignment
data-layout-padding sets the padding on all sides and the inline scroll padding, so snapped items line up with the padded edge. data-layout-align sets the cross-axis alignment; the default stretch makes every item as tall as the tallest.
123
<section data-layout="reel" data-layout-padding="l" data-layout-item-width="s" aria-label="Large padding" tabindex="0">...</section> <section data-layout="reel" data-layout-align="start" data-layout-item-width="s" aria-label="Start-aligned items" tabindex="0">...</section>
Scroll hints
Add data-scroll-hint to fade the edges of the reel, signaling there is more content to scroll. Use data-scroll-hint="start" to only fade the end edge (useful when content starts fully visible). The fade size can be customized with --scroll-hint-size.
Where scroll-driven animations are supported, each edge fades only while there is more content in that direction: the start edge stays sharp at the start, the end edge clears at the end, and a reel that does not overflow has no fade at all. Other browsers fade both edges all the time.
123456789101112
<section data-layout="reel" data-scroll-hint data-layout-item-width="s" aria-label="Both edges hint" tabindex="0">...</section> <section data-layout="reel" data-scroll-hint="start" data-layout-item-width="s" aria-label="End edge hint" tabindex="0">...</section> <section data-layout="reel" data-scroll-hint class="wide-hints" aria-label="Wide hints" tabindex="0">...</section> <style> .wide-hints { --scroll-hint-size: 3rem; }</style>
Scrollbar visibility
By default the scrollbar is hidden. Add data-layout-scrollbar to show it. It always shows under forced colours (Windows High Contrast) and on touch-only devices, where a hidden scrollbar removes the only scrolling affordance. Show it whenever mouse users without a horizontal wheel need to reach the overflow.
123
<section data-layout="reel" data-layout-gap="m" data-layout-item-width="m" data-layout-scrollbar aria-label="Items with scrollbar" tabindex="0"> ...</section>
Right to left
The reel is logical. In dir="rtl" it starts at the right edge, the scroll hints mirror (the start edge is the right-hand side), and snapping aligns items to the right.
1234567
<html lang="ar" dir="rtl"> ... <section data-layout="reel" data-scroll-hint data-layout-item-width="s" data-layout-scrollbar aria-label="عناصر" tabindex="0"> <layout-card data-variant="outlined" data-padding="m">العنصر ١</layout-card> ... </section></html>
Image gallery
123456789
<section data-layout="reel" data-layout-gap="m" data-layout-item-width="m" data-layout-scrollbar aria-label="Gallery" tabindex="0"> <figure data-media data-ratio="4:3" data-radius="m"> <img src="image1.jpg" alt="Gallery image 1" loading="lazy" /> </figure> <figure data-media data-ratio="4:3" data-radius="m"> <img src="image2.jpg" alt="Gallery image 2" loading="lazy" /> </figure> </section>
Product carousel
123456789101112
<section data-layout="reel" data-layout-gap="m" data-layout-item-width="m" aria-label="Products" tabindex="0"> <layout-card data-variant="outlined"> <layout-stack data-layout-gap="s"> <figure data-media data-ratio="1:1" data-radius="s"> <img src="product.jpg" alt="Product 1" loading="lazy" /> </figure> <strong>Product Name</strong> <span>$29.99</span> </layout-stack> </layout-card> </section>
Testimonials
1234567891011121314151617
<section data-layout="reel" data-layout-gap="l" data-layout-item-width="l" aria-label="Testimonials" tabindex="0"> <layout-card data-variant="elevated" data-padding="l"> <layout-stack data-layout-gap="m"> <p>"This product has completely transformed how we work."</p> <layout-cluster data-layout-gap="s"> <figure data-media data-ratio="1:1" data-radius="full"> <img src="avatar.jpg" alt="Avatar" loading="lazy" /> </figure> <layout-stack data-layout-gap="xs"> <strong>Jane Smith</strong> <small>CEO, TechCorp</small> </layout-stack> </layout-cluster> </layout-stack> </layout-card> </section>
Team members
123456789101112
<section data-layout="reel" data-layout-gap="m" data-layout-item-width="s" data-layout-scrollbar aria-label="Team members" tabindex="0"> <layout-card data-variant="outlined" data-padding="m"> <layout-stack data-layout-gap="s" data-layout-align="center"> <figure data-media data-ratio="1:1" data-radius="full"> <img src="alice.jpg" alt="Team member 1" loading="lazy" /> </figure> <strong>Alice Williams</strong> <small>Engineering Lead</small> </layout-stack> </layout-card> </section>
Accessibility
Keyboard access and a name
A scroll container is only reachable from the keyboard when something inside it, or the container itself, can take focus. Chrome and Firefox make a scroller with no focusable content focusable automatically; Safari does not, and nobody gives the region a name. When the items hold no links or buttons, make the reel a named, focusable region. The simplest way is the attribute form on a <section>, which is a region landmark once it has a name (the demos on this page use this form):
12345678
<section data-layout="reel" aria-label="Customer testimonials" tabindex="0"> ...</section> <layout-reel role="region" aria-label="Customer testimonials" tabindex="0"> ...</layout-reel>
Arrow keys then scroll it, and screen readers announce the region by name. When every item contains a link or button, the region attributes are optional: tabbing to an item scrolls it into view.
Scrollbar
The scrollbar is hidden by default but always shown under forced colours and on touch-only devices. Add data-layout-scrollbar where mouse users need it.
Reduced motion
The reel respects prefers-reduced-motion by disabling scroll snap for users who prefer reduced motion.
12345
@media (prefers-reduced-motion: reduce) { :is(layout-reel, [data-layout="reel"]) { scroll-snap-type: none; }}