Dialog Step Wizard
Build a multi-step wizard where each step opens as a dialog on top of the one before. data-sv-dialog-open opens the next step, data-sv-dialog-close goes back, and --sv-dialog-stack-depth shrinks and blurs the steps behind.
Reduced Motion
Your system is set to reduce motion, so the animations shown on this page will not play for you.
Name your workspace
Invite your team
All set
Your workspace is ready. Invites go out as soon as you finish.
Code
The following example assumes that you have imported the component and set up the theme.
<div class="dialog-step-wizard">1 collapsed line
<button type="button" class="btn" data-sv-dialog-toggle="wizard-step-1">Create workspace</button></div>
<sv-dialog42 collapsed lines
id="wizard-step-1" class="wizard-step" aria-labelledby="wizard-step-1-title" close-button> <span class="step-count">Step 1 of 3</span> <h2 id="wizard-step-1-title">Name your workspace</h2> <input id="wizard-workspace-name" type="text" aria-label="Workspace name" value="Acme Design" /> <div class="dialog-footer"> <button type="button" class="btn btn-primary" data-sv-dialog-open="wizard-step-2">Next</button> </div>
<sv-dialog id="wizard-step-2" class="wizard-step" aria-labelledby="wizard-step-2-title"> <span class="step-count">Step 2 of 3</span> <h2 id="wizard-step-2-title">Invite your team</h2> <input id="wizard-teammate-email" type="email" aria-label="Teammate email" placeholder="name@company.com" /> <div class="dialog-footer"> <button type="button" class="btn btn-surface" data-sv-dialog-close="wizard-step-2"> Back </button> <button type="button" class="btn btn-primary" data-sv-dialog-open="wizard-step-3"> Next </button> </div>
<sv-dialog id="wizard-step-3" class="wizard-step" aria-labelledby="wizard-step-3-title"> <span class="step-count">Step 3 of 3</span> <h2 id="wizard-step-3-title">All set</h2> <p>Your workspace is ready. Invites go out as soon as you finish.</p> <div class="dialog-footer"> <button type="button" class="btn btn-surface" data-sv-dialog-close="wizard-step-3"> Back </button> <button id="wizard-done" type="button" class="btn btn-primary">Done</button> </div> </sv-dialog> </sv-dialog></sv-dialog>
<script type="application/x-typescript" module>5 collapsed lines
document.querySelector("#wizard-done")?.addEventListener("click", () => { for (const step of document.querySelectorAll<Dialog>(".wizard-step")) { step.close(); } });</script>
<style>53 collapsed lines
.dialog-step-wizard { display: flex; justify-content: center; }
.wizard-step { --stack-dur: 450ms; --stack-ease: cubic-bezier(0.3, 1.4, 0.5, 1);
&::part(wrapper) { transition: scale var(--stack-dur) var(--stack-ease), translate var(--stack-dur) var(--stack-ease), filter var(--stack-dur) ease; }
&:state(--stacked)::part(wrapper) { filter: blur(calc(var(--sv-dialog-stack-depth) * 1px)); scale: calc(1 - var(--sv-dialog-stack-depth) * 0.06); translate: 0 calc(var(--sv-dialog-stack-depth) * -1.5rem); }
@media (prefers-reduced-motion: reduce) { --stack-dur: 0s; }
.step-count { font-size: 0.85em; color: var(--sv-gray-3); }
h2 { margin-block: 0.25em 1em !important; }
input { box-sizing: border-box; inline-size: 100%; padding: 0.5em 0.75em; font: inherit; color: inherit; background-color: var(--sv-gray-7); border: 1px solid var(--sv-gray-5); border-radius: var(--sv-bdr-rad-md); }
.dialog-footer { display: flex; gap: 0.75em; justify-content: flex-end; margin-block-start: 1.5em; } }</style>