Stepper
Address
Add your address here
Shipping
Set your preferred shipping method
Checkout
Confirm your order
Features
- Can be controlled or uncontrolled.
- Supports horizontal/vertical orientation.
- Supports linear/non-linear activation.
- Full keyboard navigation.
Installation
Install the component from your command line.
$ npm add reka-uiAnatomy
Import all parts and piece them together.
<script setup>
import { StepperDescription, StepperIndicator, StepperItem, StepperRoot, StepperSeparator, StepperTitle, StepperTrigger } from 'reka-ui'
</script>
<template>
<StepperRoot>
<StepperItem>
<StepperTrigger />
<StepperIndicator />
<StepperTitle />
<StepperDescription />
<StepperSeparator />
</StepperItem>
</StepperRoot>
</template>API Reference
Root
Contains all the stepper component parts.
| Data Attribute | Value |
|---|---|
[data-orientation] | "vertical" | "horizontal" |
[data-linear] | Present when linear |
Item
The step item component.
| Data Attribute | Value |
|---|---|
[data-state] | "active" | "inactive" | "completed" |
[data-disabled] | Present when disabled |
[data-orientation] | "vertical" | "horizontal" |
Trigger
The trigger that toggles the step.
| Data Attribute | Value |
|---|---|
[data-state] | "active" | "inactive" | "completed" |
[data-disabled] | Present when disabled |
[data-orientation] | "vertical" | "horizontal" |
Indicator
The indicator for the step.
Title
An accessible title to be announced when the stepper trigger is focused.
If you want to hide the title, wrap it inside our Visually Hidden utility like this <VisuallyHidden asChild>.
Description
An optional accessible description to be announced when the stepper trigger is focused.
If you want to hide the description, wrap it inside our Visually Hidden utility like this <VisuallyHidden asChild>. If you want to remove the description entirely, remove this part.
Separator
A visual divider between steps. It is purely decorative, follows the root's orientation, and reflects the state of the item it is placed in.
| Data Attribute | Value |
|---|---|
[data-state] | "active" | "inactive" | "completed" |
[data-orientation] | "vertical" | "horizontal" |
Examples
Vertical
You can create vertical steps by using the orientation prop.
<script setup>
import { StepperDescription, StepperIndicator, StepperItem, StepperRoot, StepperTitle } from 'reka-ui'
</script>
<template>
<StepperRoot
:default-value="1"
orientation="vertical"
>
<StepperItem>
<StepperIndicator />
<StepperTitle />
<StepperDescription />
</StepperItem>
<StepperItem>
<StepperIndicator />
<StepperTitle />
<StepperDescription />
</StepperItem>
</StepperRoot>
</template>With controls
You can add additional controls for the stepper using buttons and access the typed component instance using useTemplateRef.
<script setup lang="ts">
const stepper = useTemplateRef('stepper')
</script>
<template>
<StepperRoot
ref="stepper"
:default-value="1"
>
<StepperItem>
<StepperIndicator />
<StepperTitle />
<StepperDescription />
</StepperItem>
<StepperItem>
<StepperIndicator />
<StepperTitle />
<StepperDescription />
</StepperItem>
</StepperRoot>
<div class="flex gap-2 justify-between mt-4">
<button
:disabled="!stepper?.hasPrev()"
@click="stepper?.prevStep()"
>
Prev
</button>
<button
:disabled="!stepper?.hasNext()"
@click="stepper?.nextStep()"
>
Next
</button>
</div>
</template>Accessibility
Trigger name and current step
StepperTrigger is named by the item's rendered StepperTitle and StepperDescription, in that order, through aria-labelledby. Only the parts that are rendered are referenced. Pass an aria-label or aria-labelledby to StepperTrigger to name it yourself; the description is then exposed through aria-describedby.
The trigger of the current step has aria-current="step". StepperItem keeps aria-current="true" for styling.
Step announcements
The live region announces the active step's one-based position among the rendered steps, independently of its step value. Use announce to translate or replace the message:
<StepperRoot :announce="(step, total) => `Étape ${step} sur ${total}`">
<!-- Stepper items -->
</StepperRoot>Set :announce="false" when your application provides its own live announcement. No message is announced when the active value does not match a rendered step.
Keyboard Interactions
| Key | Description |
|---|---|
Tab | When focus moves onto the steps, focuses the first step . |
ArrowDown | Moves focus to the next step depending on orientation. |
ArrowRight | Moves focus to the next step depending on orientation . |
ArrowUp | Moves focus to the previous step depending on orientation . |
ArrowLeft | Moves focus to the previous step depending on orientation . |
EnterSpace | Selects the focused step. |
