SFX

Hover Craft

A list of steps whose cards slide up and stack over one another as you scroll, so a step-by-step feels like something happening instead of a column to skim. This first demo is the grouped variant: each step's title, text and card travel together. Scroll to see them stack.

Step 1

Pick a look

Choose a theme, or set a handful of tokens in theme.css. Colour, type and shape all come from there.

Step 2

Fill in the details

Everything a visitor sees comes from client.json: the name, the opening hours, the services.

Step 3

Add the pages

Use the sections the framework ships. A missing section becomes a new component, never one-off CSS.

Step 4

Build and look

Build the site, take screenshots at desktop and phone width, and check them by eye before anything goes out.

Step 5

Ship it

Deploy when asked. Every page is plain HTML and one bundled stylesheet, so there is nothing to keep running.

Rail

The titles stay in a rail beside the cards, so you can see how many steps there are and which one you are on. Below 800px it becomes the grouped variant. Pressing Enter on a title brings its step up.

Step 1

Pick a look

Choose a theme, or set a handful of tokens in theme.css. Colour, type and shape all come from there.

Step 2

Fill in the details

Everything a visitor sees comes from client.json: the name, the opening hours, the services.

Step 3

Add the pages

Use the sections the framework ships. A missing section becomes a new component, never one-off CSS.

Step 4

Build and look

Build the site, take screenshots at desktop and phone width, and check them by eye before anything goes out.

Step 5

Ship it

Deploy when asked. Every page is plain HTML and one bundled stylesheet, so there is nothing to keep running.

Markup

Put class="cardstack" and data-cardstack on a container, and data-cardstack-step on each step inside it (direct children). Mark each title with data-cardstack-title; the rail is built from them.

<div class="cardstack" data-cardstack="rail">
  <section data-cardstack-step>
    <h3 data-cardstack-title>Pick a look</h3>
    <p>…</p>
  </section>
  <section data-cardstack-step> … </section>
</div>

<script defer src="scripts/cardstack.3da2f559.js"></script>   <!-- only on pages that use it -->

Attributes

AttributeOnValues
data-cardstackthe containerrail (default) · grouped
data-cardstack-stepeach stepa direct child of the container; the step is the card
data-cardstack-titlethe title inside a stepits text becomes the rail entry (else "Step N")

The script adds data-cardstack-ready to the container, and --i, an id and data-state (buried · active · upcoming) to each step. It also sends cardstack:set to the container with detail { variant } to switch variant.

Tokens

The look is a token, set in the client's theme.css. For no pile, set the peek to 0.

TokenDefaultWhat it does
--cardstack-peek12pxHow much of each buried card's top edge shows. 0 = the cards cover each other completely: no pile.
--cardstack-offsetvar(--space-6)Where the stack sticks, from the top of the viewport. Raise it to clear a sticky header.
--cardstack-gapvar(--space-6)Space between the cards before they stack.
--cardstack-dim0.92Brightness of a buried card. 1 = not dimmed.
--cardstack-scale1Size of a buried card. 0.97 = slightly smaller.
--cardstack-rail-width14remWidth of the title rail.

Behaviour and limits

  • Opt-in. A site whose pages have no .cardstack gets none of its CSS or JavaScript. The script is not part of the shared bundle.
  • Plain list when it cannot run. Without JavaScript, with reduced motion, or for a card taller than the viewport, the steps are an ordinary list and nothing is hidden.
  • It is only sticky positioning. The page always scrolls at its normal speed; nothing is scroll-jacked.
  • An ancestor with overflow other than visible breaks it. Sticky cannot work inside a clipped or scrolling parent. The console warns once if it finds one.
  • A sticky header needs room. Set --cardstack-offset to the header's height plus a little.
  • Keep the cards shorter than the screen. The step is the card and it sticks whole, so a tall one is better left to scroll normally (it does, automatically).
  • Accessibility. The steps stay in reading order in the page. The rail is navigation to them, and the current step is marked aria-current="step".

Tuning

The panel at the bottom right sets the pile, dimming and scale on both demos above. Copy tokens gives the CSS for theme.css.