Stagger List
A button sends the items of a list out one after another, 80 ms apart, then brings them back in the same order on the next click. A commanded round trip, on your own elements, with the list taken out of keyboard reach while it is out. CSS + 0.9 KB of JavaScript.
Updated
This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Transitions has 52 effects, including 9 free. Explore the category →
3 usage examples



How it works
On load, the script walks the direct children of .stgl-list and writes each one's index into the --stgl-i variable (0, 1, 2…). That is its only part in the cascade: the rest is one CSS rule, transition-delay: calc(var(--stgl-i) * 80ms), which delays each item by 80 ms per index. It does not matter what those children are (rows, cards, buttons) or how many there are.
The .stgl-toggle button adds or removes the .stgl-list--out class. Added, it sends each item 30 px to the right and to opacity 0, in 0.5 s; removed, it brings them back. With five items, the last one leaves at 320 ms and everything is over at 820 ms. Read 400 ms after the click: the first is at 3% opacity, the third at 27%, the fifth still at 94%. The return follows the same order, first one leading, and a click during the movement reverses it from the position reached.
Only opacity and visual position change: the list that is out keeps its place in the page, nothing moves up to fill the gap. So it is made for a panel laid over a background, a menu that fans out or a reserved area, not for a block that would push the following content. The script keeps the state in step: when the list is out, it gets the inert attribute and the button goes to aria-expanded="false".
Accessibility
- A hidden list that is truly hidden: items at opacity 0 stay reachable by keyboard and read by screen readers. The
inertattribute set by the script removes them from both while the list is out. It is understood from Chrome 102, Firefox 112 and Safari 15.5; in an older browser, invisible buttons would remain in the tab order. - Reduced motion: no slide and no cascade. The whole list fades out or back as one block, in 150 ms of linear opacity (all five items at the same opacity, between 0.6 and 0.7 after 60 ms, at 0 before 320 ms).
- Keyboard: the control is a
<button>that announces its state througharia-expanded; Enter and Space operate it and focus stays on it. Addaria-controlswith your list'sidif you want to link them explicitly. - Target size: the demo button measures 167 × 26 px. That is above the 24 px minimum, but below the 44 px advised for fingers: increase its
paddingon mobile.
Browser compatibility
CSS (transition on transform and opacity, a delay computed by calc() from a variable, flexbox with gap) + 0.9 KB of JavaScript (style.setProperty, toggleAttribute). Same cascade read in Chromium 149, Firefox 151 and WebKit 26.5, within a few hundredths of opacity. The animation needs Chrome 84, Firefox 63 or Safari 14.1 (flexbox gap sets those versions); putting the list out of reach also needs inert, hence Chrome 102, Firefox 112 or Safari 15.5.
Without JavaScript, the list stays on screen and the button does nothing: no content is lost. If the script runs but the --stgl-i variable is not set on an item (added afterwards), that item leaves with no delay, together with the first.
The code
HTML structure to paste into your page (the CSS + JS come with your purchase):
<div class="stgl-root">
<div class="stgl-list">
<div class="stgl-item"><span class="stgl-item-dot"></span> …</div>
<div class="stgl-item"><span class="stgl-item-dot"></span> …</div>
…
</div>
<button class="stgl-toggle" type="button" aria-expanded="true">…</button>
</div>
One-time payment, no subscription — the code is yours forever
Customize
Options passed to the API or data-* attributes:
| Option / property | Default | Effect |
|---|---|---|
Gap between two items (CSS — 80ms in transition-delay) |
80 ms per index | 40 ms gives a quick wave, suited to ten items and more; 150 ms clearly separates each row but gets long beyond five. |
Direction and distance (CSS — translateX(30px) in .stgl-list--out > *) |
30 px to the right | translateX(-30px) for a list against the left edge, translateY(12px) for a menu that drops back. Opacity does most of the work: no need to go past 40 px. |
Duration of each item (CSS — .5s in both transitions) |
0.5 s | The total duration is that value plus 80 ms per item after the first: 820 ms for five, 1.2 s for ten. Shorten to 0.3 s for a long list. |
Cascade order (CSS — flex-direction on .stgl-list) |
column: top to bottom |
column-reverse starts the cascade from the bottom without touching the HTML; row spreads it left to right for a line of tags. |
Starting state (HTML — stgl-list--out and inert on the list, aria-expanded="false" on the button) |
list shown | All three written in the HTML, they make it start with the list closed: the first click fans it out. The script does not set them by itself on load. |
FAQ
--stgl-i variable and so leaves with no delay, with the first one. Give it its index when you add it: element.style.setProperty('--stgl-i', list.children.length - 1).