Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

layout-reel

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.

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

AttributeOnDescription
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:

Item widths

The data-layout-item-width attribute gives every item the same width.

Gap

The data-layout-gap attribute controls spacing between items.

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.

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.

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.

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.

Image gallery

Product carousel

Testimonials

Team members

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):

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.

Related

↑