components
/components/ui/stepper.tsx
stepper-demo.tsx
Stepper
A component that displays a series of steps and allows users to navigate between them
Installation
Usage
Imports
import {
Stepper,
StepperContent,
StepperDescription,
StepperIndicator,
StepperItem,
StepperNav,
StepperPanel,
StepperSeparator,
StepperTitle,
StepperTrigger,
} from "@/components/ui/stepper"Code
const steps = [
{ step: 1, title: "Cart", description: "Review items" },
{ step: 2, title: "Shipping", description: "Address details" },
{ step: 3, title: "Payment", description: "Billing method" },
]
<Stepper defaultValue={1} className="space-y-6">
<StepperNav>
{steps.map((item, index) => (
<StepperItem key={item.step} step={item.step}>
<StepperTrigger>
<StepperIndicator>{item.step}</StepperIndicator>
<span className="text-left">
<StepperTitle>{item.title}</StepperTitle>
<StepperDescription>{item.description}</StepperDescription>
</span>
</StepperTrigger>
{index < steps.length - 1 && <StepperSeparator />}
</StepperItem>
))}
</StepperNav>
<StepperPanel>
{steps.map((item) => (
<StepperContent key={item.step} value={item.step}>
{item.title}
</StepperContent>
))}
</StepperPanel>
</Stepper>Examples
States
Controlled
Vertical
Custom Indicators
Props
<Stepper>
| Name | Default | Values |
|---|---|---|
| defaultValue | 1 | number |
| value | - | number |
| onValueChange | - | (value: number) => void |
| orientation | horizontal | horizontalvertical |
| indicators | - | StepIndicators |
| className | - | string |
<StepperItem>
| Name | Default | Values |
|---|---|---|
| step* | - | number |
| completed | false | boolean |
| disabled | false | boolean |
| loading | false | boolean |
| className | - | string |
<StepperTrigger>
| Name | Default | Values |
|---|---|---|
| asChild | false | boolean |
| disabled | - | boolean |
| className | - | string |
<StepperIndicator>
| Name | Default | Values |
|---|---|---|
| children | - | ReactNode |
| className | - | string |
<StepperSeparator>
| Name | Default | Values |
|---|---|---|
| className | - | string |
<StepperTitle>
| Name | Default | Values |
|---|---|---|
| children | - | ReactNode |
| className | - | string |
<StepperDescription>
| Name | Default | Values |
|---|---|---|
| children | - | ReactNode |
| className | - | string |
<StepperNav>
| Name | Default | Values |
|---|---|---|
| className | - | string |
<StepperPanel>
| Name | Default | Values |
|---|---|---|
| className | - | string |
<StepperContent>
| Name | Default | Values |
|---|---|---|
| value* | - | number |
| forceMount | false | boolean |
| className | - | string |