Vanilla Breeze

data-stagger

Cascades timing to child elements for choreographed entrance sequences.

Overview

The data-stagger attribute goes on a parent element. It sets --vb-stagger-index on each child (0, 1, 2, ...) so CSS can calculate cascading delays for entrance effects.

Basic usage

Each child appears 80ms after the previous one, creating a cascading entrance.

How it works

VB.js sets --vb-stagger-index on each direct child. The built-in CSS rule calculates the delay:

Effects that support --vb-delay (like fade-in, slide-up, pop) automatically pick up the staggered timing.

Choreography

Combine stagger with different effects for varied choreography patterns.

Custom timing

Override the stagger interval with a CSS custom property or inline style:

Ordering modes

By default data-stagger orders children by DOM position. Mode keywords change the index assignment:

ModeEffect
(default / time value)Linear DOM order: child 0 gets index 0, child 1 gets index 1, etc.
reverseLast child gets index 0, first child gets the highest index.
randomFisher-Yates shuffle seeded by the parent's id (or generated UID), so the order is deterministic across reloads.
gridManhattan distance from the top-left grid cell. Uses each child's computed grid-row-start / grid-column-start; falls back to DOM order outside a grid.

Attribute reference

AttributeApplied toDescription
data-staggerParent elementEmpty or a CSS time (e.g. "80ms") → linear cascade. reverse / random / grid → alternate ordering. CSS-time values set --vb-stagger on the parent as a shorthand.
CSS PropertySet onDescription
--vb-stagger-indexEach childAuto-set by JS (0, 1, 2, ...). Used in delay calculation.
--vb-staggerParentOverrides the stagger interval. Falls back to attribute value or 80ms.