Stepper
The steps of a longer flow: a tick for the ones done, a ring around the one you are on and a quiet number for the rest. The line between two steps fills as you move on.
- Services Completed
- Budget Completed
- 3 Timeline Current step
- 4 Details Up next
When should we start?
Pick a rough date. We confirm the exact week once the brief is agreed.
Options
Code
import "./stepper.css";
const words = { done: "Completed", active: "Current step", next: "Up next" };
/* The steps of a longer flow. steps is a list of names, and current is the
number of the step the person is on, counting from 0.
<Stepper steps={["Services", "Budget", "Timeline", "Details"]} current={2} /> */
export function Stepper({ steps, current, label = "Progress" }) {
return (
<ol className="dh-stepper" aria-label={label}>
{steps.map((step, index) => {
const state = index < current ? "done" : index === current ? "active" : "next";
return (
<li
key={step}
data-state={state === "next" ? undefined : state}
aria-current={state === "active" ? "step" : undefined}
>
<i>
{state === "done" ? (
<svg viewBox="0 0 12 12" aria-hidden="true">
<path d="M2.500 6.300 5 8.700l4.500-5.200" />
</svg>
) : (
index + 1
)}
</i>
<span>
{step} <small>{words[state]}</small>
</span>
</li>
);
})}
</ol>
);
}
export function Example() {
return (
<section className="dh-stepper-card">
<Stepper steps={["Services", "Budget", "Timeline", "Details"]} current={2} />
<div>
<h3>When should we start?</h3>
<p>Pick a rough date. We confirm the exact week once the brief is agreed.</p>
</div>
<footer>
<button type="button">Back</button>
<button type="button">Continue</button>
</footer>
</section>
);
}/* The steps of a longer flow, shown at the top of a small card: a glossy tick
for the steps done, an accent ring around the one you are on and a quiet
number for the rest. The line between two steps fills as you move on. */
.dh-stepper {
--accent: var(--dh-accent, #2563ff);
--line: color-mix(in srgb, var(--dh-fg, #171717) 9%, transparent);
container: dh-stepper / inline-size;
display: flex;
align-items: center;
margin: 0;
padding: 0;
list-style: none;
color: var(--dh-fg, #171717);
font-size: 13px;
line-height: 20px;
}
.dh-stepper li {
display: flex;
flex: 1;
align-items: center;
gap: 8px;
min-width: 0;
color: var(--dh-faint, #8a8a8a);
white-space: nowrap;
}
.dh-stepper li:last-child {
flex: none;
}
/* The line to the next step. */
.dh-stepper li:not(:last-child)::after {
content: "";
flex: 1;
min-width: 12px;
height: 1.5px;
margin-right: 8px;
border-radius: 1px;
background: linear-gradient(90deg, var(--accent) 50%, color-mix(in srgb, var(--dh-fg, #171717) 12%, transparent) 0) 100% 0 / 200% 100%;
transition: background-position 400ms cubic-bezier(0.23, 1, 0.32, 1);
}
.dh-stepper li[data-state="done"]::after {
background-position: 0 0;
}
.dh-stepper i {
display: grid;
flex: none;
place-items: center;
width: 20px;
height: 20px;
border-radius: 50%;
background: var(--dh-well, #ededeb);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 11px;
font-style: normal;
line-height: 1;
transition:
background-color 200ms cubic-bezier(0.23, 1, 0.32, 1),
box-shadow 200ms cubic-bezier(0.23, 1, 0.32, 1);
}
.dh-stepper svg {
width: 10px;
height: 10px;
fill: none;
stroke: var(--dh-on-accent, #fff);
stroke-width: 1.75;
stroke-linecap: round;
stroke-linejoin: round;
}
.dh-stepper span {
overflow: hidden;
font-weight: 500;
letter-spacing: -0.01em;
text-overflow: ellipsis;
}
/* The state in words, for screen readers only. */
.dh-stepper small {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
}
.dh-stepper li[data-state="done"] {
color: var(--dh-muted, #5c5c5c);
}
.dh-stepper li[data-state="done"] i {
background: linear-gradient(color-mix(in srgb, var(--accent) 84%, #fff), var(--accent));
box-shadow:
inset 0 1px 0 rgb(255 255 255 / 0.3),
0 0 0 1px color-mix(in srgb, var(--accent) 78%, #000),
0 1px 2px color-mix(in srgb, var(--dh-fg, #171717) 22%, transparent);
}
.dh-stepper li[data-state="active"] {
color: var(--dh-fg, #171717);
}
.dh-stepper li[data-state="active"] i {
background: var(--dh-raised, #fff);
color: color-mix(in srgb, var(--accent) 85%, var(--dh-fg, #171717));
box-shadow:
0 0 0 1.5px var(--accent),
0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}
/* In a narrow space only the step you are on keeps its name. */
@container dh-stepper (max-width: 380px) {
.dh-stepper li:not([data-state="active"]) span {
display: none;
}
}
/* The card around it in the example. */
.dh-stepper-card {
--accent: var(--dh-accent, #2563ff);
--line: color-mix(in srgb, var(--dh-fg, #171717) 9%, transparent);
width: 480px;
max-width: 100%;
overflow: hidden;
border-radius: 14px;
background: var(--dh-raised, #fff);
box-shadow:
0 0 0 1px var(--line),
0 1px 2px color-mix(in srgb, var(--dh-fg, #171717) 10%, transparent);
color: var(--dh-fg, #171717);
font-family: inherit;
font-size: 13px;
line-height: 20px;
text-align: left;
}
.dh-stepper-card .dh-stepper {
padding: 14px 16px;
border-bottom: 1px solid var(--line);
}
.dh-stepper-card > div {
padding: 16px 16px 20px;
}
.dh-stepper-card h3 {
margin: 0;
font-size: 14px;
font-weight: 500;
line-height: 20px;
letter-spacing: -0.015em;
}
.dh-stepper-card p {
margin: 2px 0 0;
color: var(--dh-muted, #5c5c5c);
}
.dh-stepper-card footer {
display: flex;
justify-content: space-between;
padding: 10px;
border-top: 1px solid var(--line);
background: color-mix(in srgb, var(--dh-fg, #171717) 3%, var(--dh-raised, #fff));
}
.dh-stepper-card button {
height: 32px;
padding: 0 12px;
border: 0;
border-radius: 8px;
background: var(--dh-raised, #fff);
color: inherit;
font: inherit;
font-weight: 500;
letter-spacing: -0.01em;
cursor: pointer;
box-shadow:
0 0 0 1px var(--line),
0 1px 2px color-mix(in srgb, var(--dh-fg, #171717) 10%, transparent);
transition: transform 150ms cubic-bezier(0.23, 1, 0.32, 1);
}
.dh-stepper-card button:last-child {
background: linear-gradient(color-mix(in srgb, var(--accent) 84%, #fff), var(--accent));
color: var(--dh-on-accent, #fff);
box-shadow:
inset 0 1px 0 rgb(255 255 255 / 0.3),
0 0 0 1px color-mix(in srgb, var(--accent) 78%, #000),
0 1px 2px color-mix(in srgb, var(--dh-fg, #171717) 22%, transparent);
}
.dh-stepper-card button:active {
transform: scale(0.97);
}
.dh-stepper-card button:focus-visible {
outline: 2px solid var(--dh-faint, #8a8a8a);
outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
.dh-stepper li::after,
.dh-stepper i,
.dh-stepper-card button {
transition: none;
}
}<section class="dh-stepper-card">
<ol class="dh-stepper" aria-label="Progress">
<li data-state="done">
<i><svg viewBox="0 0 12 12" aria-hidden="true"><path d="M2.500 6.300 5 8.700l4.500-5.200" /></svg></i>
<span>Services <small>Completed</small></span>
</li>
<li data-state="done">
<i><svg viewBox="0 0 12 12" aria-hidden="true"><path d="M2.500 6.300 5 8.700l4.500-5.200" /></svg></i>
<span>Budget <small>Completed</small></span>
</li>
<li data-state="active" aria-current="step">
<i>3</i>
<span>Timeline <small>Current step</small></span>
</li>
<li>
<i>4</i>
<span>Details <small>Up next</small></span>
</li>
</ol>
<div>
<h3>When should we start?</h3>
<p>Pick a rough date. We confirm the exact week once the brief is agreed.</p>
</div>
<footer>
<button type="button">Back</button>
<button type="button">Continue</button>
</footer>
</section>/* The steps of a longer flow, shown at the top of a small card: a glossy tick
for the steps done, an accent ring around the one you are on and a quiet
number for the rest. The line between two steps fills as you move on. */
.dh-stepper {
--accent: var(--dh-accent, #2563ff);
--line: color-mix(in srgb, var(--dh-fg, #171717) 9%, transparent);
container: dh-stepper / inline-size;
display: flex;
align-items: center;
margin: 0;
padding: 0;
list-style: none;
color: var(--dh-fg, #171717);
font-size: 13px;
line-height: 20px;
}
.dh-stepper li {
display: flex;
flex: 1;
align-items: center;
gap: 8px;
min-width: 0;
color: var(--dh-faint, #8a8a8a);
white-space: nowrap;
}
.dh-stepper li:last-child {
flex: none;
}
/* The line to the next step. */
.dh-stepper li:not(:last-child)::after {
content: "";
flex: 1;
min-width: 12px;
height: 1.5px;
margin-right: 8px;
border-radius: 1px;
background: linear-gradient(90deg, var(--accent) 50%, color-mix(in srgb, var(--dh-fg, #171717) 12%, transparent) 0) 100% 0 / 200% 100%;
transition: background-position 400ms cubic-bezier(0.23, 1, 0.32, 1);
}
.dh-stepper li[data-state="done"]::after {
background-position: 0 0;
}
.dh-stepper i {
display: grid;
flex: none;
place-items: center;
width: 20px;
height: 20px;
border-radius: 50%;
background: var(--dh-well, #ededeb);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 11px;
font-style: normal;
line-height: 1;
transition:
background-color 200ms cubic-bezier(0.23, 1, 0.32, 1),
box-shadow 200ms cubic-bezier(0.23, 1, 0.32, 1);
}
.dh-stepper svg {
width: 10px;
height: 10px;
fill: none;
stroke: var(--dh-on-accent, #fff);
stroke-width: 1.75;
stroke-linecap: round;
stroke-linejoin: round;
}
.dh-stepper span {
overflow: hidden;
font-weight: 500;
letter-spacing: -0.01em;
text-overflow: ellipsis;
}
/* The state in words, for screen readers only. */
.dh-stepper small {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
}
.dh-stepper li[data-state="done"] {
color: var(--dh-muted, #5c5c5c);
}
.dh-stepper li[data-state="done"] i {
background: linear-gradient(color-mix(in srgb, var(--accent) 84%, #fff), var(--accent));
box-shadow:
inset 0 1px 0 rgb(255 255 255 / 0.3),
0 0 0 1px color-mix(in srgb, var(--accent) 78%, #000),
0 1px 2px color-mix(in srgb, var(--dh-fg, #171717) 22%, transparent);
}
.dh-stepper li[data-state="active"] {
color: var(--dh-fg, #171717);
}
.dh-stepper li[data-state="active"] i {
background: var(--dh-raised, #fff);
color: color-mix(in srgb, var(--accent) 85%, var(--dh-fg, #171717));
box-shadow:
0 0 0 1.5px var(--accent),
0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent);
}
/* In a narrow space only the step you are on keeps its name. */
@container dh-stepper (max-width: 380px) {
.dh-stepper li:not([data-state="active"]) span {
display: none;
}
}
/* The card around it in the example. */
.dh-stepper-card {
--accent: var(--dh-accent, #2563ff);
--line: color-mix(in srgb, var(--dh-fg, #171717) 9%, transparent);
width: 480px;
max-width: 100%;
overflow: hidden;
border-radius: 14px;
background: var(--dh-raised, #fff);
box-shadow:
0 0 0 1px var(--line),
0 1px 2px color-mix(in srgb, var(--dh-fg, #171717) 10%, transparent);
color: var(--dh-fg, #171717);
font-family: inherit;
font-size: 13px;
line-height: 20px;
text-align: left;
}
.dh-stepper-card .dh-stepper {
padding: 14px 16px;
border-bottom: 1px solid var(--line);
}
.dh-stepper-card > div {
padding: 16px 16px 20px;
}
.dh-stepper-card h3 {
margin: 0;
font-size: 14px;
font-weight: 500;
line-height: 20px;
letter-spacing: -0.015em;
}
.dh-stepper-card p {
margin: 2px 0 0;
color: var(--dh-muted, #5c5c5c);
}
.dh-stepper-card footer {
display: flex;
justify-content: space-between;
padding: 10px;
border-top: 1px solid var(--line);
background: color-mix(in srgb, var(--dh-fg, #171717) 3%, var(--dh-raised, #fff));
}
.dh-stepper-card button {
height: 32px;
padding: 0 12px;
border: 0;
border-radius: 8px;
background: var(--dh-raised, #fff);
color: inherit;
font: inherit;
font-weight: 500;
letter-spacing: -0.01em;
cursor: pointer;
box-shadow:
0 0 0 1px var(--line),
0 1px 2px color-mix(in srgb, var(--dh-fg, #171717) 10%, transparent);
transition: transform 150ms cubic-bezier(0.23, 1, 0.32, 1);
}
.dh-stepper-card button:last-child {
background: linear-gradient(color-mix(in srgb, var(--accent) 84%, #fff), var(--accent));
color: var(--dh-on-accent, #fff);
box-shadow:
inset 0 1px 0 rgb(255 255 255 / 0.3),
0 0 0 1px color-mix(in srgb, var(--accent) 78%, #000),
0 1px 2px color-mix(in srgb, var(--dh-fg, #171717) 22%, transparent);
}
.dh-stepper-card button:active {
transform: scale(0.97);
}
.dh-stepper-card button:focus-visible {
outline: 2px solid var(--dh-faint, #8a8a8a);
outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
.dh-stepper li::after,
.dh-stepper i,
.dh-stepper-card button {
transition: none;
}
}Stepper is not in the Figma file yet.
Use the React or HTML code for now.