Stepper Examples
The examples below assume that you have imported the component and set up the theme.
Basic
Show the progress through a checkout and move between its steps with Back and Next buttons. next() and previous() move current, a currentchange listener updates the buttons, and orientation="auto" stacks the steps when they do not fit in a row.
The clickable control lets the user click a step.
<div class="stepper-basic"> <sv-stepper aria-label="Checkout" current="1" orientation="auto"> <sv-step> Cart <span slot="description">Your items</span> </sv-step> <sv-step> Shipping <span slot="description">Your address</span> </sv-step> <sv-step> Payment <span slot="description">Your card</span> </sv-step> <sv-step> Review <span slot="description">Your order</span> </sv-step> </sv-stepper>
<div class="stepper-basic-buttons"> <button type="button" class="btn stepper-basic-back">Back</button> <button type="button" class="btn btn-primary stepper-basic-next">Next</button> </div></div>
<script type="application/x-typescript" module> const stepper = document.querySelector<Stepper>(".stepper-basic sv-stepper")!; const backButton = document.querySelector<HTMLButtonElement>(".stepper-basic-back")!; const nextButton = document.querySelector<HTMLButtonElement>(".stepper-basic-next")!;
const syncButtons = () => { backButton.disabled = stepper.current <= 0; nextButton.disabled = stepper.current >= stepper.steps.length; };
backButton.addEventListener("click", () => stepper.previous()); nextButton.addEventListener("click", () => stepper.next()); stepper.addEventListener("currentchange", syncButtons); syncButtons();</script>
<style> .stepper-basic { display: grid; gap: 2em; overflow-x: auto; }
.stepper-basic-buttons { display: flex; gap: 0.5em; justify-content: center; }</style>Right to Left
Show the steps of an Arabic flow from right to left. dir="rtl" on an ancestor mirrors the order of the steps and the lines, and clickable lets the user click a step.
<div class="stepper-rtl" dir="rtl" lang="ar"> <sv-stepper aria-label="الدفع" clickable current="1" orientation="auto"> <sv-step> السلة <span slot="description">ثلاثة منتجات</span> </sv-step> <sv-step> الشحن <span slot="description">عنوان التوصيل</span> </sv-step> <sv-step> الدفع <span slot="description">بطاقة بنكية</span> </sv-step> </sv-stepper></div>
<style> .stepper-rtl { display: grid; overflow-x: auto; }</style>Progress
Show how far a step has come, like a file upload. progress="40" fills a ring around the marker and the line to the next step to 40%.
The progress control sets progress on the Upload step.
<div class="stepper-progress"> <sv-stepper aria-label="Upload" current="1" orientation="auto"> <sv-step> Select <span slot="description">3 files</span> </sv-step> <sv-step progress="40"> Upload <span slot="description">40% sent</span> </sv-step> <sv-step> Share <span slot="description">Get a link</span> </sv-step> </sv-stepper></div>
<style> .stepper-progress { display: grid; overflow-x: auto; }</style>Loading
Show that a step is still running, like a deploy in progress. loading shows a spinner in the marker in place of the number.
The attention control sets attention on the Deploy step.
Your system is set to reduce motion. This animation will not play for you.
<div class="stepper-loading"> <sv-stepper aria-label="Deployment" current="2" orientation="auto"> <sv-step> Build <span slot="description">Done in 42 s</span> </sv-step> <sv-step> Tests <span slot="description">Done in 18 s</span> </sv-step> <sv-step loading> Deploy <span slot="description">Uploading</span> </sv-step> </sv-stepper></div>
<style> .stepper-loading { display: grid; overflow-x: auto; }</style>Variants
Show the result of each check in a review. variant colors the marker and shows a check for success, a warning sign for warning, and a cross for error.
<div class="stepper-variants"> <sv-stepper aria-label="Pull request checks" current="3" orientation="auto"> <sv-step variant="success"> Build <span slot="description">Passed</span> </sv-step> <sv-step variant="warning"> Lint <span slot="description">3 warnings</span> </sv-step> <sv-step variant="error"> Tests <span slot="description">2 failed</span> </sv-step> </sv-stepper></div>
<style> .stepper-variants { display: grid; overflow-x: auto; }</style>Custom Icons
Show an icon in each marker in place of the number. The icon slot replaces the number, the check, the warning sign, and the cross.
<div class="stepper-icons"> <sv-stepper aria-label="Account setup" current="1" orientation="auto"> <sv-step> <!-- User --> <svg aria-hidden="true" slot="icon" viewBox="0 0 24 24"> <path d="M20 21a8 8 0 0 0-16 0M12 13a5 5 0 1 0 0-10 5 5 0 0 0 0 10" /> </svg> Profile <span slot="description">Your name</span> </sv-step> <sv-step> <!-- Mail --> <svg aria-hidden="true" slot="icon" viewBox="0 0 24 24"> <path d="M3 5h18v14H3zm0 2 9 6 9-6" /> </svg> Email <span slot="description">Your inbox</span> </sv-step> <sv-step> <!-- Lock --> <svg aria-hidden="true" slot="icon" viewBox="0 0 24 24"> <path d="M5 11h14v10H5zm3 0V7a4 4 0 0 1 8 0v4" /> </svg> Password <span slot="description">Your secret</span> </sv-step> </sv-stepper></div>
<style> .stepper-icons { display: grid; overflow-x: auto;
svg { inline-size: 1em; fill: none; stroke: currentcolor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; } }</style>Current Description
Show long help text for the step the user is on, and keep the other steps short. descriptions="current" shows the description of the current step only, and the Back and Next buttons move current with previous() and next().
<div class="stepper-current-description"> <sv-stepper aria-label="Onboarding" current="1" descriptions="current" orientation="vertical"> <sv-step> Create your account <span slot="description"> Pick a username and a strong password. You can sign in with Google or GitHub instead. </span> </sv-step> <sv-step> Set up your profile <span slot="description"> Add your name and a photo so your team knows who you are. You can change both later. </span> </sv-step> <sv-step> Invite your team <span slot="description"> Send invites by email or share a link. People join as members, and you can make them admins. </span> </sv-step> <sv-step> Start your first project <span slot="description"> Pick a template or start from scratch. Your project is private until you share it. </span> </sv-step> </sv-stepper>
<div class="stepper-current-description-buttons"> <button type="button" class="btn stepper-current-description-back">Back</button> <button type="button" class="btn btn-primary stepper-current-description-next">Next</button> </div></div>
<script type="application/x-typescript" module> const stepper = document.querySelector<Stepper>(".stepper-current-description sv-stepper")!; const backButton = document.querySelector<HTMLButtonElement>( ".stepper-current-description-back" )!; const nextButton = document.querySelector<HTMLButtonElement>( ".stepper-current-description-next" )!;
const syncButtons = () => { backButton.disabled = stepper.current <= 0; nextButton.disabled = stepper.current >= stepper.steps.length; };
backButton.addEventListener("click", () => stepper.previous()); nextButton.addEventListener("click", () => stepper.next()); stepper.addEventListener("currentchange", syncButtons); syncButtons();</script>
<style> .stepper-current-description { display: grid; gap: 2em; overflow-x: auto; }
.stepper-current-description-buttons { display: flex; gap: 0.5em; justify-content: center; }</style>Many Steps
Fit a long flow into a small width. max sets how many steps show at once and collapses the steps far from current into an ellipsis, and clickable lets the user jump to a step.
<div class="stepper-many-steps"> <sv-stepper aria-label="Workspace setup" clickable current="5" label-placement="bottom" max="5" orientation="auto" > <sv-step>Account</sv-step> <sv-step>Profile</sv-step> <sv-step>Team</sv-step> <sv-step>Billing</sv-step> <sv-step>Domain</sv-step> <sv-step>Email</sv-step> <sv-step>Storage</sv-step> <sv-step>Security</sv-step> <sv-step>Apps</sv-step> <sv-step>Alerts</sv-step> <sv-step>Theme</sv-step> <sv-step>Launch</sv-step> </sv-stepper>
<div class="stepper-many-steps-buttons"> <button type="button" class="btn stepper-many-steps-back">Back</button> <button type="button" class="btn btn-primary stepper-many-steps-next">Next</button> </div></div>
<script type="application/x-typescript" module> const stepper = document.querySelector<Stepper>(".stepper-many-steps sv-stepper")!; const backButton = document.querySelector<HTMLButtonElement>(".stepper-many-steps-back")!; const nextButton = document.querySelector<HTMLButtonElement>(".stepper-many-steps-next")!;
const syncButtons = () => { backButton.disabled = stepper.current <= 0; nextButton.disabled = stepper.current >= stepper.steps.length; };
backButton.addEventListener("click", () => stepper.previous()); nextButton.addEventListener("click", () => stepper.next()); stepper.addEventListener("currentchange", syncButtons); syncButtons();</script>
<style> .stepper-many-steps { display: grid; gap: 2em; overflow-x: auto; }
.stepper-many-steps-buttons { display: flex; gap: 0.5em; justify-content: center; }</style>