Steps
Used to guide users through a series of steps in a process
Anatomy
<Steps.Root>
<Steps.List>
<Steps.Item>
<Steps.Trigger>
<Steps.Indicator />
</Steps.Trigger>
<Steps.Separator />
</Steps.Item>
</Steps.List>
<Steps.Content />
<Steps.CompletedContent />
<Steps.PrevTrigger />
<Steps.NextTrigger />
</Steps.Root>
Examples
Basic
Controlled
Use value and onValueChange to control the active step.
Root Provider
Use RootProvider with the useSteps hook to access the state and methods from outside the component.
Vertical
Set orientation="vertical" to stack the steps.
API Reference
Props
Root
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
items | StepItem[]The steps of the stepper | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
completedValues | string[]The controlled values of the completed steps | |
defaultCompletedValues | string[]The initial values of the completed steps when rendered. Use when you don't need to control the completed steps. | |
defaultValue | stringThe initial value of the stepper when rendered. Use when you don't need to control the value of the stepper. | |
id | stringThe unique identifier of the machine. | |
ids | ElementIdsThe custom ids for the stepper elements | |
linear | booleanIf `true`, the stepper requires the user to complete the steps in order | |
onComplete | (details: CompleteDetails) => voidCallback to be called when the user moves past the last step. With a controlled value, it fires on each request, whether or not you apply it. | |
onCompletedChange | (details: CompletedChangeDetails) => voidCallback to be called when the completed steps change. Also fires on `goToNext`, which marks the step it leaves as completed. | |
onNavigationBlocked | (details: NavigationBlockedDetails) => voidCallback to be called when navigation is blocked | |
onValueChange | (details: ValueChangeDetails) => voidCallback to be called when the value changes | |
orientation | 'horizontal' | 'horizontal' | 'vertical'The orientation of the stepper |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. | |
translations | IntlTranslationsThe localized messages to use | |
value | stringThe controlled value of the stepper. `COMPLETE` is the position past the last step. |
| Attribute | Description |
|---|---|
[data-steps-root] | <uid> |
[data-orientation] | The orientation of the steps |
[data-complete] | Present when the steps value is complete |
| CSS Variable | Description |
|---|---|
--steps-percent | The steps percent value for the Root |
CompletedContent
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-steps-content] | <uid> |
[data-type] | "complete" |
[data-state] | "open" | "closed" |
[data-orientation] | The orientation of the completedcontent |
Content
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
value | stringThe value of the step item | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-steps-content] | <uid> |
[data-value] | The value of the item |
[data-type] | "step" |
[data-state] | "open" | "closed" |
[data-orientation] | The orientation of the content |
[data-complete] | Present when the content value is complete |
Indicator
Defines the <span> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-steps-indicator] | <uid> |
[data-orientation] | The orientation of the indicator |
[data-value] | The value of the item |
[data-complete] | Present when the indicator value is complete |
[data-current] | Present when current |
[data-incomplete] | Present when incomplete |
[data-skipped] | Present when the flow moved past it without completing it |
[data-invalid] | Present when invalid |
[data-optional] | Present when optional |
[data-locked] | Present when completed and it cannot be returned to |
[data-disabled] | Present when disabled |
Item
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
value | stringThe value of the step item | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<StepsItemState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-steps-item] | <uid> |
[data-orientation] | The orientation of the item |
[data-value] | The value of the item |
[data-complete] | Present when the item value is complete |
[data-current] | Present when current |
[data-incomplete] | Present when incomplete |
[data-skipped] | Present when the flow moved past it without completing it |
[data-invalid] | Present when invalid |
[data-optional] | Present when optional |
[data-locked] | Present when completed and it cannot be returned to |
[data-disabled] | Present when disabled |
List
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-steps-list] | <uid> |
[data-orientation] | The orientation of the list |
NextTrigger
Defines the <button> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
PrevTrigger
Defines the <button> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Progress
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-steps-progress] | <uid> |
[data-complete] | Present when the progress value is complete |
RootProvider
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
value | UseStepsReturn | |
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Separator
Defines the <div> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-steps-separator] | <uid> |
[data-orientation] | The orientation of the separator |
[data-value] | The value of the item |
[data-complete] | Present when the separator value is complete |
[data-current] | Present when current |
[data-incomplete] | Present when incomplete |
[data-skipped] | Present when the flow moved past it without completing it |
[data-invalid] | Present when invalid |
[data-optional] | Present when optional |
[data-locked] | Present when completed and it cannot be returned to |
[data-disabled] | Present when disabled |
SkipTrigger
Defines the <button> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
Trigger
Defines the <button> element.
| Attribute | Default | Type |
|---|---|---|
asChild | booleanUse the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`. For more details, read our Composition guide. | |
render | ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state. |
| Attribute | Description |
|---|---|
[data-steps-trigger] | <uid> |
[data-state] | "open" | "closed" |
[data-orientation] | The orientation of the trigger |
[data-value] | The value of the item |
[data-complete] | Present when the trigger value is complete |
[data-current] | Present when current |
[data-incomplete] | Present when incomplete |
[data-skipped] | Present when the flow moved past it without completing it |
[data-invalid] | Present when invalid |
[data-optional] | Present when optional |
[data-locked] | Present when completed and it cannot be returned to |
[data-disabled] | Present when disabled |
Context
API
| Property | Type |
|---|---|
items | V[]The steps in the flow, excluding disabled ones |
value | string | nullThe value of the current step, `COMPLETE` past the last step, or `null` when there are no steps |
index | numberThe position of the current step in the flow |
item | V | nullThe current step item |
count | numberThe number of steps in the flow, excluding disabled ones |
percent | numberThe percentage of the stepper |
complete | booleanWhether the stepper has moved past the last step |
completedValues | string[]The values of the completed steps |
hasNextStep | booleanWhether the stepper has a next step |
hasPreviousStep | booleanWhether the stepper has a previous step |
canSkip | booleanWhether the current step is optional and can be skipped |
canComplete | booleanWhether `goToNextStep` would complete the stepper |
getItemState | (props: ItemProps) => ItemStateReturns the state of the item with the given value |
setValue | (value: string) => voidFunction to set the value of the stepper |
goToNextStep | VoidFunctionFunction to go to the next step |
goToPreviousStep | VoidFunctionFunction to go to the previous step |
skipStep | VoidFunctionFunction to skip the current step. Only works when the step is optional. |
resetStep | VoidFunctionFunction to reset the stepper to its initial state |
setCompletedValues | (values: string[]) => voidFunction to set the completed steps |
getRootState | () => RootStateReturns the state of the root |
getCompletedContentProps | () => T["element"]Returns the props for the content shown once the flow is complete |