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

content-swap

Two-face content toggle with flip, fade, slide, and scale transitions. Theme-driven motion via design tokens.

Overview

The <content-swap> component toggles between two content faces with configurable transition effects. It manages inert on the hidden face so screen readers only announce visible content.

The transition type is a styling concern (transition), while duration and easing come from VB motion tokens — so themes automatically control the personality of every swap.

Attributes

Attribute Type Default Description
transition string flip Transition effect: flip, flip-vertical, fade, slide-left, slide-up, scale.
swapped boolean false Reflects the current swap state. Can be set to start swapped, or set/removed later — inert follows the attribute.
card boolean — Applies layout-card visual shell (background, radius, shadow).
data-variant string — Card variant when using card: elevated, outlined, ghost.

Child Attributes

Attribute Where Description
data-face="front" Direct child Marks the front face.
data-face="back" Direct child Marks the back face.
data-swap Any descendant Marks an element as a swap trigger. Use a <button type="button">.
data-swap-toggle Direct child Toggle button used when there are no data-swap triggers. Generated (text “Show back”) if absent; author your own <button type="button" data-swap-toggle> to set or localize the label. Kept in sync via aria-pressed.

Transition Effects

Each transition reads from VB motion tokens, so themes automatically control personality.

Value Animation Kawaii Brutalist
flip 3D rotateY Bouncy easing, 300ms Instant cut
flip-vertical 3D rotateX Bouncy easing Instant cut
fade Crossfade opacity 300ms fade Hard opacity toggle
slide-left Horizontal slide Slide with bounce Hard slide, linear
slide-up Vertical slide Slide with bounce Hard slide, linear
scale Scale + opacity Pop with bounce Linear scale

Trigger Buttons

By default (no data-swap triggers), clicking the surface swaps for pointer users, and a generated <button data-swap-toggle> — visually hidden until it receives keyboard focus — is the keyboard and screen-reader control. Clicks on links, buttons and form fields inside a face keep their own behavior.

Add data-swap to specific buttons for explicit, always-visible trigger controls. When triggers exist, the surface is no longer clickable and no toggle is generated.

Card Mode

Add card to apply layout-card's visual shell directly on the swap element. Supports data-variant for elevated, outlined, and ghost styles.

Page-level auto-card

Add data-swap-autocard to a container or <body> to automatically apply card chrome to all content-swap elements that don't already wrap <layout-card> children.

Composition

Wrap <layout-card> elements as faces for full card structure (header, section, footer) on each side.

The composition example is the third card in the Card Mode demo above.

Attribute Form

For authors who want swap behavior on an existing element, add data-swap as an attribute on any element with data-face children. The behavior auto-initializes via JavaScript (the host gets data-swap-init once upgraded). Use data-transition and data-swapped in place of transition and swapped. The second example in the Trigger Buttons demo uses this form.

Keyboard Navigation

Key Action
Enter / Space Toggle swap (when the generated toggle or a data-swap trigger is focused)
Tab Move focus to next interactive element

Events

Event Detail Description
content-swap:swap { swapped: boolean, source: 'pointer' | 'keyboard' | 'api' } Fired after the content swaps. source says what caused it: a click or swipe, a keyboard activation, or a method/property call.

JavaScript API

Method / Property Description
flip() Swap to show the back face.
unflip() Swap to show the front face.
toggle() Toggle between front and back.
swapped Boolean property reflecting the current state.
flipped Alias for swapped (backward compatibility).

Theme Integration

Content-swap reads from VB motion tokens. Themes override these tokens, so personality comes for free:

  • Default: --motion-enter-duration: 300ms, --ease-default: var(--ease-3)
  • Kawaii: Bouncy easing (cubic-bezier(0.34, 1.56, 0.64, 1)), 300ms
  • Brutalist: Linear easing, 0ms (instant cut)

No extra theme CSS needed — the token bridge handles it.

Accessibility

Inert Toggling

The hidden face is always marked inert. Screen readers only announce the currently visible face, and interactive elements on the hidden face cannot receive focus.

Trigger Modes

  • Whole-element mode (no data-swap children): the container is never turned into a button, so headings, links and other face content stay individually reachable. A real <button type="button" data-swap-toggle aria-pressed> is appended outside both faces (so it is never made inert); it is visually hidden until focused, then shown over the corner of the card. Surface clicks are a pointer convenience only.
  • Explicit triggers (data-swap children): the trigger buttons are the keyboard targets. Nothing is added to the container. Use <button type="button">; a trigger that is not a button or link is given role="button" and tabindex="0" (unless it already has them) and responds to Enter and Space.

Focus Management

An element with autofocus on the incoming face is always focused. Otherwise focus only moves on keyboard swaps whose focus was inside the outgoing face (for example a data-swap trigger that is about to become inert): it goes to the first trigger, button, link or field on the incoming face. Pointer and API swaps leave focus alone, and the generated toggle keeps focus because it sits outside both faces.

Reduced Motion

When prefers-reduced-motion: reduce is active, the swap animation duration is set to 0s. The state still toggles instantly without animation.

Progressive Enhancement

Without JavaScript, both faces display stacked in natural document flow. Stacking into one grid cell and the transition transforms only apply once upgraded (content-swap:defined or [data-swap][data-swap-init]), and the first upgrade settles without animating.

Related

↑