# Step-by-step Guide

Opening a step reveals the instructions for that part of a process.

## Try it

Expand a step to read its instructions and collapse it again when finished.

## Interaction details

Keep the step headings in order while their instructions expand beneath them.

## Where to use it

Procedures with a clear sequence, such as preparing for a workshop.

## Implementation prompt

> Let people expand the guidance they need from each step heading.

## Sources and credits

- [GOV.UK driving guide](<https://www.gov.uk/learn-to-drive-a-car>)
- [Design Museum award history](<https://designmuseum.org/design/beazley-designs-of-the-year-overview>)

## Checking the behavior

Open the first and third stages with the keyboard and leave both expanded. Expand all opens every stage, and Collapse all closes them. Each individual disclosure also works with JavaScript disabled. Opening an instruction changes its visibility and keeps its task-completion state independent.

## Standalone HTML

Save the code below as an HTML file and open it in your browser. The example works offline.

```html
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<title>Prepare an Exhibition Entry · UI Motion Lab</title>
<style>:root{color-scheme:light;--paper:#f5f3ec;--ink:#262820;--line:#c7c6b7;--accent:#98402b}
*{box-sizing:border-box}body{margin:0;background:var(--paper);color:var(--ink);font:15px/1.55 Arial,'Apple SD Gothic Neo','Malgun Gothic',sans-serif;overflow-wrap:anywhere}
main{width:min(810px,calc(100% - 36px));margin:clamp(20px,5vh,58px) auto}
main h1{margin:0;font-size:clamp(28px,4.1vw,47px);font-weight:700;line-height:1.15;letter-spacing:-.065em}
main>p{color:#56594e;margin:8px 0 22px;line-height:1.55}.panel{padding:clamp(15px,2.7vw,28px);background:#fffdf6;border:1px solid var(--line);border-radius:2px}
button,select,input,textarea{font:inherit}button,select{min-height:40px}button{cursor:pointer}button:disabled{cursor:default;opacity:.45}
button,select{background:#faf9f0;color:inherit;border:1px solid #a6a798;border-radius:3px;padding:5px 12px}
:focus-visible{outline:3px solid #945030;outline-offset:3px}button:enabled:hover,select:hover{border-color:var(--ink)}
[hidden]{display:none!important}.lab-embedded [data-lab-shell]{display:none!important}.lab-embedded main{margin:clamp(12px,2vh,25px) auto}
figure,fieldset{margin:0}p:last-child{margin-bottom:0}fieldset{min-width:0}
@media(max-width:460px){main{width:calc(100% - 24px);margin:16px auto}main>p{font-size:13px;margin:5px 0 14px}main h1{font-size:26px}.panel{padding:13px}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.01ms!important;transition-duration:.01ms!important;scroll-behavior:auto!important}}
.lab-reduce *,.lab-reduce *::before,.lab-reduce *::after{animation-duration:.01ms!important;transition-duration:.01ms!important;scroll-behavior:auto!important}
.panel{background:#fff9ef;border-top:4px solid #784632}.guide-summary{display:flex;align-items:center;justify-content:space-between;gap:10px}.reading{font-size:12px;color:#5d574c}
#all{min-height:34px;font-size:13px}.panel ol{padding:0;margin:10px 0 0;list-style:none}.panel li{border-top:1px solid #c8bcaa}
summary{display:flex;align-items:center;gap:16px;min-height:48px;list-style:none;cursor:pointer;font-size:clamp(16px,2.4vw,23px);font-weight:620;letter-spacing:-.04em}
summary::-webkit-details-marker{display:none}summary::after{content:'+';margin-left:auto;font:23px/1 Georgia,serif;color:#6c4932}details[open] summary::after{content:'−'}
.step-num{font:italic 17px/1.1 Georgia,serif;color:#8a503b}.detail-copy{margin:0 0 14px clamp(22px,4vw,40px);padding-left:12px;border-left:2px solid #a46c4e}.detail-copy p{margin:0;font-size:14px}.detail-copy dl{display:flex;gap:8px;margin:.25em 0 0;font-size:12px}.detail-copy dt{color:#7a503a;white-space:nowrap}.detail-copy dd{margin:0}
</style>
<script>
const viewOptions=new URLSearchParams(location.search);
document.documentElement.classList.toggle('lab-embedded',viewOptions.get('embed')==='1');
document.documentElement.classList.toggle('lab-reduce',viewOptions.get('reduce')==='1');
</script>
</head>
<body class="lab-example">
<main><h1>Prepare an Exhibition Entry</h1><p>Expand a step to see what to submit and what to check before delivery.</p>
<section class="panel" aria-label="Submission steps">
 <div class="guide-summary"><span class="reading" role="status">3 steps</span><button type="button" id="all" hidden>Expand all</button></div>
 <ol>
 <li><details><summary><span class="step-num" aria-hidden="true">01</span>Measure the work</summary><div class="detail-copy"><p>Measure the width, height, and depth using the same units.</p><dl><dt>What to prepare</dt><dd>Dimensions of the work, including its frame or base</dd></dl></div></details></li>
 <li><details><summary><span class="step-num" aria-hidden="true">02</span>Prepare submission materials</summary><div class="detail-copy"><p>Write a description, choose a photo, and check the date it was taken.</p><dl><dt>What to prepare</dt><dd>Title, materials, year, and a representative photo</dd></dl></div></details></li>
 <li><details><summary><span class="step-num" aria-hidden="true">03</span>Choose a delivery time</summary><div class="detail-copy"><p>Estimate the installation time and decide when to arrive.</p><dl><dt>Checklist</dt><dd>Packed dimensions, delivery route, and installation order</dd></dl></div></details></li>
 </ol>
</section>
</main>
<script>

const items = Array.from(document.querySelectorAll("details"));
const all = document.querySelector("#all");
function syncLabel() {
  const count=items.filter(item=>item.open).length;
  all.textContent = count===items.length ? "Collapse all" : "Expand all";
  document.querySelector(".reading").textContent="Steps expanded:  "+count+" of 3";
}
all.hidden = false;
items.forEach(item => item.addEventListener("toggle", syncLabel));
all.addEventListener("click", () => {
  const expand = !items.every(item => item.open);
  items.forEach(item => { item.open = expand; });
  syncLabel();
});
</script>
</body></html>
```
