import { Button } from "@senvenli/react/action";
import { Stack } from "@senvenli/react/layout";
import { Stepper } from "@senvenli/react/navigation";
import { useState } from "react";
const STEPS = [
{ id: "cart", label: "Cart" },
{ id: "delivery", label: "Delivery" },
{ id: "payment", label: "Payment" },
{ id: "review", label: "Review" },
];
export default function Example() {
const [current, setCurrent] = useState("payment");
const next = STEPS[STEPS.findIndex((step) => step.id === current) + 1];
return (
<Stack space="space-300" align="start">
<div className="w-full">
<Stepper aria-label="Checkout" steps={STEPS} currentStep={current} onStepPress={setCurrent} />
</div>
<Button variant="primary" isDisabled={!next} onPress={() => next && setCurrent(next.id)}>
Continue
</Button>
</Stack>
);
}import { Stepper } from "@senvenli/react/navigation";Examples
A vertical checklist
Each step has a line of detail: onboarding, setup.import { Stepper } from "@senvenli/react/navigation";
export default function Example() {
return (
<Stepper
aria-label="Workspace setup"
orientation="vertical"
currentStep="team"
steps={[
{ id: "account", label: "Create your account", description: "Name, email and password." },
{ id: "workspace", label: "Name the workspace", description: "Shown on invoices and emails." },
{ id: "team", label: "Invite your team", description: "Add at least one other member." },
{ id: "billing", label: "Add a payment method", description: "Charged when the trial ends." },
]}
/>
);
}A journey with statuses
Steps that wait on someone or failed say so in words and an icon.import { Stepper } from "@senvenli/react/navigation";
export default function Example() {
return (
<Stepper
aria-label="Payout setup"
orientation="vertical"
currentStep="documents"
steps={[
{ id: "signup", label: "Sign up", isDone: true },
{ id: "documents", label: "Identity documents", description: "Upload a photo of your ID.", status: "needs-you" },
{ id: "bank", label: "Bank account", status: "with-provider", statusText: "With the bank · 1–2 business days" },
{ id: "tax", label: "Tax details", description: "The tax number did not match. Enter it again.", status: "failed" },
]}
/>
);
}Finished
With isComplete every step shows done and none is current.import { Stepper } from "@senvenli/react/navigation";
export default function Example() {
return (
<Stepper
aria-label="Order progress"
isComplete
currentStep="delivered"
steps={[
{ id: "placed", label: "Placed" },
{ id: "packed", label: "Packed" },
{ id: "shipped", label: "Shipped" },
{ id: "delivered", label: "Delivered" },
]}
/>
);
}Guidelines
When to use it
- A flow of three or more steps: checkout, signup, setup.
Accessibility
Built in
- The current step has aria-current; the list is named with the overall progress.
You provide
- Short step names.
API reference
Stepper
| Prop | Type | Default | Description |
|---|---|---|---|
stepsRequired | readonly StepperStep[] | – | Three to six steps, in order. |
currentStepRequired | string | – | The step the reader is on: |
isComplete | boolean | – | The flow is finished: every step shows its done state and none is current, so no step carries |
onStepPress | (id: string) => void | – | Makes done steps pressable (back to an earlier step). Leave it out where the flow cannot go back. |
orientation | "horizontal" | "vertical" | – |
|
showStatus | boolean | – | Done and current steps say so in words too ("Done", "Now"), as on a journey across pages. On by default when any step has a |
aria-label | string | – | Names the list; "Progress" by default. |
stepsRequiredreadonly StepperStep[]Three to six steps, in order.
currentStepRequiredstringThe step the reader is on:
aria-current="step". Ignored withisComplete.isCompletebooleanThe flow is finished: every step shows its done state and none is current, so no step carries
aria-current. The list is named with the overall state ("Progress, All steps done"), and the narrow one-line form reads "All steps done" over a full bar. A step'sstatusorstatusTextstill speaks for it, in the list and, under the done line, in the narrow form too ("Domain · With us"). A finished flow cannot also have afailedorneeds-youstep: that pairing contradicts itself and warns in development; settle the step first. Left out, nothing changes.onStepPress(id: string) => voidMakes done steps pressable (back to an earlier step). Leave it out where the flow cannot go back.
orientation"horizontal" | "vertical"horizontalfor a flow on one page (checkout, signup);verticalfor checklists (onboarding, setup).showStatusbooleanDone and current steps say so in words too ("Done", "Now"), as on a journey across pages. On by default when any step has a
status.aria-labelstringNames the list; "Progress" by default.