← All items

Staircase reveal

effect · page-transition · T0 · v1.0.0 · ready

About

Covers its content with a row of columns that retract upwards one after another, from the left or the right, so the content shows through in steps. Runs once when it mounts; remount it (a new React key) to replay. Without motion the content is shown at once.

Use the item page's Replay (R) to run it again.

Layers

Native
No gated feature: supported everywhere.
Static
No cover: the content is shown at once.

Skin

VariableDefaultMeaning
--staircase-reveal-cover#171717Colour of the cover.
--staircase-reveal-duration600msHow long one column takes to retract.
--staircase-reveal-stagger80msDelay between one column and the next.
--staircase-reveal-delay0msDelay before the first column moves.
--staircase-reveal-easingcubic-bezier(0.65, 0, 0.35, 1)Easing of each column.

Accessibility

Static layer: no cover, the content is shown at once.

The cover is aria-hidden and never catches pointer events; the content is in the accessibility tree from the start.

Sources

  • reel · thedesignshop.tds · "Easter Eggs" reel; technique only (P6).

Code

Download zip

Self-contained: copy every file, keeping the folder structure.

cover.tsx
// web-effects staircase-reveal 1.0.0 · MIT-0
import type { CSSProperties } from "react";
import mechanism from "./mechanism.module.css";

// The cover, shared by both styling variants (P8): `steps` columns, each told its position in
// the sequence, counted from the side the reveal starts at.

export function Cover({
  steps,
  from,
}: {
  steps: number;
  from: "left" | "right";
}) {
  return (
    <div className={mechanism.cover} aria-hidden="true">
      {Array.from({ length: steps }, (_, index) => (
        <span
          key={index}
          className={mechanism.step}
          style={
            {
              "--_staircase-reveal-order":
                from === "left" ? index : steps - 1 - index,
            } as CSSProperties
          }
        />
      ))}
    </div>
  );
}
mechanism.module.css
/* web-effects staircase-reveal 1.0.0 · MIT-0 */
/* Mechanism of the staircase reveal (D2.8, D3.11), shared by both styling variants.
   .cover lies over the content: a row of equal .step columns, each with its position in the
   sequence set inline (--_staircase-reveal-order). Each column shrinks upwards (scaleY 1 → 0,
   origin at the top) after order × stagger, so the content appears from the bottom in steps.
   L1: CSS animations, run by every supported browser, so the native layer has no feature gate
   and there is no L2. L3 (base rules): no cover at all. */
.root {
  --_staircase-reveal-cover: var(--staircase-reveal-cover, #171717);
  --_staircase-reveal-duration: var(--staircase-reveal-duration, 600ms);
  --_staircase-reveal-stagger: var(--staircase-reveal-stagger, 80ms);
  --_staircase-reveal-delay: var(--staircase-reveal-delay, 0ms);
  --_staircase-reveal-easing: var(
    --staircase-reveal-easing,
    cubic-bezier(0.65, 0, 0.35, 1)
  );
  position: relative;
}

/* Never catches pointer events: the content is usable as soon as it shows. Clips the last
   column's overlap (below). */
.cover {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
  pointer-events: none;
}

/* Columns overlap by a pixel so no hairline of content shows between them. */
.step {
  flex: 1 0 0;
  margin-inline-end: -1px;
  background: var(--_staircase-reveal-cover);
  transform-origin: 50% 0;
}

@keyframes retract {
  from {
    transform: scaleY(1);
  }
  to {
    transform: scaleY(0);
  }
}

/* L1 native (gated on the override attribute, D3.6a). `both`: covered before the column's
   delay, gone after its end. */
:root:not([data-fx-layer]) .cover,
:root[data-fx-layer="native"] .cover {
  display: flex;
}

:root:not([data-fx-layer]) .step,
:root[data-fx-layer="native"] .step {
  animation: retract var(--_staircase-reveal-duration)
    var(--_staircase-reveal-easing) both;
  animation-delay: calc(
    var(--_staircase-reveal-delay) + var(--_staircase-reveal-order) *
      var(--_staircase-reveal-stagger)
  );
}

/* L3 under reduced motion (unless forced): no cover. */
@media (prefers-reduced-motion: reduce) {
  :root:not([data-fx-layer]) .cover {
    display: none;
  }
}
tailwind/StaircaseReveal.tsx
// web-effects staircase-reveal 1.0.0 · MIT-0
import type { ReactNode } from "react";
import { Cover } from "../cover";
import mechanism from "../mechanism.module.css";

/**
 * Reveals `children` from under a cover of `steps` columns retracting one after another,
 * starting `from` the left or the right. Runs on mount; give it a new `key` to replay.
 */
export function StaircaseReveal({
  children,
  steps = 8,
  from = "left",
  className = "",
}: {
  children: ReactNode;
  steps?: number;
  from?: "left" | "right";
  className?: string;
}) {
  return (
    <div className={`${mechanism.root} ${className}`}>
      {children}
      <Cover steps={steps} from={from} />
    </div>
  );
}