import { Button, ButtonGroup, Steps } from "@chakra-ui/react"
const Demo = () => {
return (
<Steps.Root defaultStep={1} count={steps.length}>
<Steps.List>
{steps.map((step, index) => (
<Steps.Item key={index} index={index} title={step.title}>
<Steps.Indicator />
<Steps.Title>{step.title}</Steps.Title>
<Steps.Separator />
</Steps.Item>
))}
</Steps.List>
{steps.map((step, index) => (
<Steps.Content key={index} index={index}>
{step.description}
</Steps.Content>
))}
<Steps.CompletedContent>All steps are complete!</Steps.CompletedContent>
<ButtonGroup size="sm" variant="outline">
<Steps.PrevTrigger asChild>
<Button>Prev</Button>
</Steps.PrevTrigger>
<Steps.NextTrigger asChild>
<Button>Next</Button>
</Steps.NextTrigger>
</ButtonGroup>
</Steps.Root>
)
}
const steps = [
{
title: "Step 1",
description: "Step 1 description",
},
{
title: "Step 2",
description: "Step 2 description",
},
{
title: "Step 3",
description: "Step 3 description",
},
]
Usage
import { Steps } from "@chakra-ui/react"
<Steps.Root>
<Steps.List>
<Steps.Item>
<Steps.Trigger>
<Steps.Indicator />
<Steps.Title />
<Steps.Description />
</Steps.Trigger>
<Steps.Separator />
</Steps.Item>
</Steps.List>
<Steps.Content />
<Steps.CompletedContent />
<Steps.PrevTrigger />
<Steps.NextTrigger />
</Steps.Root>
Examples
Sizes
Use the size
prop to change the size of the steps component.
import { Button, ButtonGroup, For, Stack, Steps } from "@chakra-ui/react"
const Demo = () => {
return (
<Stack gap="16">
<For each={["sm", "md", "lg"]}>
{(size) => (
<Steps.Root key={size} size={size} count={steps.length}>
<Steps.List>
{steps.map((step, index) => (
<Steps.Item key={index} index={index} title={step.title}>
<Steps.Indicator />
<Steps.Title>{step.title}</Steps.Title>
<Steps.Separator />
</Steps.Item>
))}
</Steps.List>
{steps.map((step, index) => (
<Steps.Content key={index} index={index}>
{step.description}
</Steps.Content>
))}
<Steps.CompletedContent>
All steps are complete!
</Steps.CompletedContent>
<ButtonGroup size="sm" variant="outline">
<Steps.PrevTrigger asChild>
<Button>Prev</Button>
</Steps.PrevTrigger>
<Steps.NextTrigger asChild>
<Button>Next</Button>
</Steps.NextTrigger>
</ButtonGroup>
</Steps.Root>
)}
</For>
</Stack>
)
}
const steps = [
{
title: "Step 1",
description: "Step 1 description",
},
{
title: "Step 2",
description: "Step 2 description",
},
{
title: "Step 3",
description: "Step 3 description",
},
]
Variants
Use the variant
prop to change the appearance of the steps component.
import { Button, ButtonGroup, For, Stack, Steps } from "@chakra-ui/react"
const Demo = () => {
return (
<Stack gap="16">
<For each={["subtle", "solid"]}>
{(variant) => (
<Steps.Root key={variant} variant={variant} count={steps.length}>
<Steps.List>
{steps.map((step, index) => (
<Steps.Item key={index} index={index} title={step.title}>
<Steps.Indicator />
<Steps.Title>{step.title}</Steps.Title>
<Steps.Separator />
</Steps.Item>
))}
</Steps.List>
{steps.map((step, index) => (
<Steps.Content key={index} index={index}>
{step.description}
</Steps.Content>
))}
<Steps.CompletedContent>
All steps are complete!
</Steps.CompletedContent>
<ButtonGroup size="sm" variant="outline">
<Steps.PrevTrigger asChild>
<Button>Prev</Button>
</Steps.PrevTrigger>
<Steps.NextTrigger asChild>
<Button>Next</Button>
</Steps.NextTrigger>
</ButtonGroup>
</Steps.Root>
)}
</For>
</Stack>
)
}
const steps = [
{
title: "Step 1",
description: "Step 1 description",
},
{
title: "Step 2",
description: "Step 2 description",
},
{
title: "Step 3",
description: "Step 3 description",
},
]
Colors
Use the colorPalette
prop to change the color scheme of the component.
import { Button, ButtonGroup, For, Stack, Steps } from "@chakra-ui/react"
import { colorPalettes } from "compositions/lib/color-palettes"
const Demo = () => {
return (
<Stack gap="10" width="full">
<For each={colorPalettes}>
{(colorPalette) => (
<Steps.Root
key={colorPalette}
defaultStep={1}
count={steps.length}
colorPalette={colorPalette}
>
<Steps.List>
{steps.map((step, index) => (
<Steps.Item key={index} index={index} title={step.title}>
<Steps.Indicator />
<Steps.Title>{step.title}</Steps.Title>
<Steps.Separator />
</Steps.Item>
))}
</Steps.List>
{steps.map((step, index) => (
<Steps.Content key={index} index={index}>
{step.description}
</Steps.Content>
))}
<Steps.CompletedContent>
All steps are complete!
</Steps.CompletedContent>
<ButtonGroup size="sm" variant="outline">
<Steps.PrevTrigger asChild>
<Button>Prev</Button>
</Steps.PrevTrigger>
<Steps.NextTrigger asChild>
<Button>Next</Button>
</Steps.NextTrigger>
</ButtonGroup>
</Steps.Root>
)}
</For>
</Stack>
)
}
const steps = [
{
title: "Step 1",
description: "Step 1 description",
},
{
title: "Step 2",
description: "Step 2 description",
},
{
title: "Step 3",
description: "Step 3 description",
},
]
Trigger
Use the Steps.Trigger
component to make the step clickable.
import { Button, ButtonGroup, Steps } from "@chakra-ui/react"
const Demo = () => {
return (
<Steps.Root defaultStep={1} count={steps.length}>
<Steps.List>
{steps.map((step, index) => (
<Steps.Item key={index} index={index} title={step.title}>
<Steps.Trigger>
<Steps.Indicator />
<Steps.Title>{step.title}</Steps.Title>
</Steps.Trigger>
<Steps.Separator />
</Steps.Item>
))}
</Steps.List>
{steps.map((step, index) => (
<Steps.Content key={index} index={index}>
{step.description}
</Steps.Content>
))}
<Steps.CompletedContent>All steps are complete!</Steps.CompletedContent>
<ButtonGroup size="sm" variant="outline">
<Steps.PrevTrigger asChild>
<Button>Prev</Button>
</Steps.PrevTrigger>
<Steps.NextTrigger asChild>
<Button>Next</Button>
</Steps.NextTrigger>
</ButtonGroup>
</Steps.Root>
)
}
const steps = [
{
title: "Step 1",
description: "Step 1 description",
},
{
title: "Step 2",
description: "Step 2 description",
},
{
title: "Step 3",
description: "Step 3 description",
},
]
Vertical
Use the orientation
prop to change the orientation of the steps component.
import { Button, ButtonGroup, Stack, Steps } from "@chakra-ui/react"
const Demo = () => {
return (
<Steps.Root
orientation="vertical"
height="400px"
defaultStep={1}
count={steps.length}
>
<Steps.List>
{steps.map((step, index) => (
<Steps.Item key={index} index={index} title={step.title}>
<Steps.Indicator />
<Steps.Title>{step.title}</Steps.Title>
<Steps.Separator />
</Steps.Item>
))}
</Steps.List>
<Stack>
{steps.map((step, index) => (
<Steps.Content key={index} index={index}>
{step.description}
</Steps.Content>
))}
<Steps.CompletedContent>All steps are complete!</Steps.CompletedContent>
<ButtonGroup size="sm" variant="outline">
<Steps.PrevTrigger asChild>
<Button>Prev</Button>
</Steps.PrevTrigger>
<Steps.NextTrigger asChild>
<Button>Next</Button>
</Steps.NextTrigger>
</ButtonGroup>
</Stack>
</Steps.Root>
)
}
const steps = [
{
title: "Step 1",
description: "Step 1 description",
},
{
title: "Step 2",
description: "Step 2 description",
},
{
title: "Step 3",
description: "Step 3 description",
},
]
Controlled
Use the step
and onStepChange
props to control the current step of the steps
component.
"use client"
import { Button, ButtonGroup, Steps } from "@chakra-ui/react"
import { useState } from "react"
const Demo = () => {
const [step, setStep] = useState(1)
return (
<Steps.Root
step={step}
onStepChange={(e) => setStep(e.step)}
count={steps.length}
>
<Steps.List>
{steps.map((step, index) => (
<Steps.Item key={index} index={index} title={step.title}>
<Steps.Indicator />
<Steps.Title>{step.title}</Steps.Title>
<Steps.Separator />
</Steps.Item>
))}
</Steps.List>
{steps.map((step, index) => (
<Steps.Content key={index} index={index}>
{step.description}
</Steps.Content>
))}
<Steps.CompletedContent>All steps are complete!</Steps.CompletedContent>
<ButtonGroup size="sm" variant="outline">
<Steps.PrevTrigger asChild>
<Button>Prev</Button>
</Steps.PrevTrigger>
<Steps.NextTrigger asChild>
<Button>Next</Button>
</Steps.NextTrigger>
</ButtonGroup>
</Steps.Root>
)
}
const steps = [
{
title: "Step 1",
description: "Step 1 description",
},
{
title: "Step 2",
description: "Step 2 description",
},
{
title: "Step 3",
description: "Step 3 description",
},
]
Store
An alternative way to control the steps is to use the RootProvider
component
and the useSteps
store hook.
This way you can access the steps state and methods from outside the steps.
current step: 1
"use client"
import {
Button,
ButtonGroup,
Code,
Stack,
Steps,
useSteps,
} from "@chakra-ui/react"
const Demo = () => {
const steps = useSteps({
defaultStep: 1,
count: items.length,
})
return (
<Stack align="flex-start">
<Code>current step: {steps.value}</Code>
<Steps.RootProvider value={steps}>
<Steps.List>
{items.map((step, index) => (
<Steps.Item key={index} index={index} title={step.title}>
<Steps.Indicator />
<Steps.Title>{step.title}</Steps.Title>
<Steps.Separator />
</Steps.Item>
))}
</Steps.List>
{items.map((step, index) => (
<Steps.Content key={index} index={index}>
{step.description}
</Steps.Content>
))}
<Steps.CompletedContent>All steps are complete!</Steps.CompletedContent>
<ButtonGroup size="sm" variant="outline">
<Steps.PrevTrigger asChild>
<Button>Prev</Button>
</Steps.PrevTrigger>
<Steps.NextTrigger asChild>
<Button>Next</Button>
</Steps.NextTrigger>
</ButtonGroup>
</Steps.RootProvider>
</Stack>
)
}
const items = [
{
title: "Step 1",
description: "Step 1 description",
},
{
title: "Step 2",
description: "Step 2 description",
},
{
title: "Step 3",
description: "Step 3 description",
},
]
Icon
Pass the icon
prop to the StepsItem
component to display an icon.
import { Button, ButtonGroup, Steps } from "@chakra-ui/react"
import { LuCalendar, LuCheck, LuUser, LuWallet } from "react-icons/lu"
const Demo = () => {
return (
<Steps.Root defaultStep={1} count={steps.length} size="sm">
<Steps.List>
{steps.map((step, index) => (
<Steps.Item key={index} index={index}>
<Steps.Indicator>
<Steps.Status incomplete={step.icon} complete={<LuCheck />} />
</Steps.Indicator>
<Steps.Separator />
</Steps.Item>
))}
</Steps.List>
{steps.map((step, index) => (
<Steps.Content key={index} index={index}>
{step.description}
</Steps.Content>
))}
<Steps.CompletedContent>All steps are complete!</Steps.CompletedContent>
<ButtonGroup size="sm" variant="outline">
<Steps.PrevTrigger asChild>
<Button>Prev</Button>
</Steps.PrevTrigger>
<Steps.NextTrigger asChild>
<Button>Next</Button>
</Steps.NextTrigger>
</ButtonGroup>
</Steps.Root>
)
}
const steps = [
{
icon: <LuUser />,
description: "Contact Details",
},
{
icon: <LuWallet />,
description: "Payment",
},
{
icon: <LuCalendar />,
description: "Book an Appointment",
},
]
Description
Pass the description
prop to the StepsItem
component to display a
description.
import { Box, Button, ButtonGroup, Steps } from "@chakra-ui/react"
const Demo = () => {
return (
<Steps.Root defaultStep={1} count={steps.length}>
<Steps.List>
{steps.map((step, index) => (
<Steps.Item key={index} index={index} title={step.title}>
<Steps.Indicator />
<Box>
<Steps.Title>{step.title}</Steps.Title>
<Steps.Description>{step.description}</Steps.Description>
</Box>
<Steps.Separator />
</Steps.Item>
))}
</Steps.List>
{steps.map((step, index) => (
<Steps.Content key={index} index={index}>
{step.content}
</Steps.Content>
))}
<Steps.CompletedContent>All steps are complete!</Steps.CompletedContent>
<ButtonGroup size="sm" variant="outline">
<Steps.PrevTrigger asChild>
<Button>Prev</Button>
</Steps.PrevTrigger>
<Steps.NextTrigger asChild>
<Button>Next</Button>
</Steps.NextTrigger>
</ButtonGroup>
</Steps.Root>
)
}
const steps = [
{
title: "Step 1",
content: "Step 1 content",
description: "This step",
},
{
title: "Step 2",
content: "Step 2 content",
description: "That step",
},
{
title: "Step 3",
content: "Step 3 content",
description: "Final step",
},
]
Props
Root
Prop | Default | Type |
---|---|---|
orientation | 'horizontal' | 'vertical' | 'horizontal' The orientation of the component |
colorPalette | 'gray' | 'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'cyan' | 'purple' | 'pink' The color palette of the component |
variant | 'solid' | 'solid' | 'subtle' The variant of the component |
size | 'md' | 'xs' | 'sm' | 'md' | 'lg' The size of the component |
asChild | boolean Use the provided child element as the default rendered element, combining their props and behavior. For more details, read our Composition guide. | |
count | number The total number of steps | |
defaultStep | number The initial value of the step | |
ids | ElementIds The custom ids for the stepper elements | |
linear | boolean If `true`, the stepper requires the user to complete the steps in order | |
onStepChange | (details: StepChangeDetails) => void Callback to be called when the value changes | |
onStepComplete | VoidFunction Callback to be called when a step is completed | |
step | number The current value of the stepper | |
as | React.ElementType The underlying element to render. | |
unstyled | boolean Whether to remove the component's style. |