Steps
Shows the steps of a process, such as a checkout, and which step the user is on.
Usage
import { Steps } from '@leverui/components';
<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.
Variants
Use the variant prop to change the appearance of the steps component.
Colors
Use the colorPalette prop to change the color scheme of the component.
Trigger
Use the Steps.Trigger component to make the step clickable.
Vertical
Use the orientation prop to change the orientation of the steps component.
Controlled
Use the value and onValueChange props to control the current step of the steps component.
Validation
Mark an item invalid to stop navigation past it in linear mode. Use the onNavigationBlocked prop to handle the blocked transition.
Registration complete!
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: step-1Icon
Pass an icon to Steps.Status within Steps.Indicator to display an icon.
Description
Render a Steps.Description beside the Steps.Title to display a description.
Guides
count, each item's index and each content panel's index must match. In a
form, linear with isStepValid blocks moving on until the current step is
valid. onStepInvalid is called when a move is blocked. Give each step a short
title and show each validation error next to its field.
Props
Root
| Prop | Default | Type | Description |
|---|---|---|---|
isStepSkippable | () => false | (index: number) => boolean | Returns whether a step can be skipped. Next and previous pass over those. |
isStepValid | () => true | (index: number) => boolean | Returns whether a step is valid. In linear mode, an invalid step blocks moving forward. |
orientation | horizontal | 'vertical' | 'horizontal' | Steps run across the page or down it. |
colorPalette | gray | 'gray' | 'red' | 'orange' | 'yellow' | 'green' | 'teal' | 'blue' | 'cyan' | 'purple' | 'pink' | Color palette. |
variant | solid | 'solid' | 'subtle' or responsive map | Steps style. |
size | md | 'xs' | 'sm' | 'md' | 'lg' or responsive map | Steps size. |
as | div | Native HTML tag | HTML tag to render. |
asChild | — | Solid render function | Render your own element with the root's props. |
unstyled | false | boolean | Turn off the Lever UI styles. |
count | — | number | Total number of steps. |
defaultStep | — | number | Current step on first render, when uncontrolled. |
ids | — | ElementIds | Your own ids for the elements inside. |
linear | — | boolean | Require the steps to be completed in order. |
onStepChange | — | (details: StepsChangeDetails) => void | Called when the current step changes. |
onStepComplete | — | VoidFunction | Called when a step is completed. |
onStepInvalid | — | (details: StepInvalidDetails) => void | Called when an invalid step blocks a move. |
step | — | number | Current step, when you control it. |
Accepts class and style. unstyled also works on a single part.
Customize with CSS
Override the public variables or style the part classes. Every public part,
including Number and CompletedContent, has a stable .leverui-steps__*
class.
.my-steps {
--leverui-colors-color-palette-solid: #145a80;
}
.my-steps .leverui-steps__indicator {
border-radius: 0.5rem;
}
Put the my-steps class on Steps.Root.
Explorer
Click a part name to highlight it in the preview.
Component Anatomy
Hover to highlight, click to select parts