Navigation and progress
Stepper
Progress through a multi-step flow.
Example
Each step is a CrStep with a label; only the content of the current step is displayed. With navigation, "Previous" and "Next" buttons ("Finish" on the last step) are added: the step title comes in from the side you move towards and leaves the other way when going back. By default (variant="line"), a glowing bead runs along the line and lights up the step reached.
import { CrStep, CrStepper } from '@cristal-ui/react';
export default function StepperBasic() {
return (
<CrStepper label="Sign-up" navigation style={{ width: '100%' }}>
<CrStep label="Account">Choose an email address and a password.</CrStep>
<CrStep label="Profile">Add your name and a photo.</CrStep>
<CrStep label="Plan">Choose your plan.</CrStep>
<CrStep label="Finish">Check your details, then confirm.</CrStep>
</CrStepper>
);
}Styles
The variant property changes how progress is shown:
| Value | Effect |
|---|---|
line | Bead Line: a glowing bead runs along the line and lights up the next step (default) |
number | Big Number: a large number flips like a split-flap display, the step name rolls in |
path | Skill Path: a zigzag path; the current step bounces three times |
blocks | Level Blocks: stair-step blocks fill up one after another, a bead jumps onto the current step |
gauge | Gauge Arc: a half-circle gauge whose needle springs to the next mark |
timeline | steps are stacked vertically, joined by a line that fills up; a completed step gets a check mark |
import { CrStep, CrStepper } from '@cristal-ui/react';
const styles = [
['number', 'Big Number'],
['path', 'Skill Path'],
['blocks', 'Level Blocks'],
['gauge', 'Gauge Arc'],
] as const;
export default function StepperStyles() {
return (
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(260px, 1fr))', gap: 32, width: '100%' }}>
{styles.map(([variant, name]) => (
<CrStepper key={variant} variant={variant} label={name} navigation>
<CrStep label="Account">Email address and password.</CrStep>
<CrStep label="Profile">Name and photo.</CrStep>
<CrStep label="Plan">Plan selection.</CrStep>
<CrStep label="Finish">Review.</CrStep>
</CrStepper>
))}
</div>
);
}Vertical steps
With variant="timeline", each step displays its title and content inside the progress line. Put your own buttons in the steps and call the next() method: the step is checked, the line fills up, the next step opens and receives focus. After the last step, onCrComplete is emitted.
3 items, $128.40
12 Lilac Lane, Austin, TX 78701
Card ending in 4242
'use client';
import { useRef, useState } from 'react';
import { CrButton, CrStep, CrStepper } from '@cristal-ui/react';
export default function StepperTimeline() {
const steps = useRef<HTMLCrStepperElement>(null);
const [complete, setComplete] = useState(false);
const next = () => steps.current?.next();
return (
<div style={{ width: '100%' }}>
<CrStepper ref={steps} variant="timeline" label="Order" onCrComplete={() => setComplete(true)}>
<CrStep label="Cart">
<p>3 items, $128.40</p>
<CrButton size="s" onClick={next}>Continue</CrButton>
</CrStep>
<CrStep label="Address">
<p>12 Lilac Lane, Austin, TX 78701</p>
<CrButton size="s" onClick={next}>Continue</CrButton>
</CrStep>
<CrStep label="Payment">
<p>Card ending in 4242</p>
<CrButton size="s" onClick={next}>Pay</CrButton>
</CrStep>
</CrStepper>
<p role="status">{complete ? 'Order confirmed.' : ''}</p>
</div>
);
}Controlling the steps
currentgives the current step (0 for the first one); it equals the number of steps once everything is completed.- The
next(),previous()andgoTo(index)methods change the step, from arefin React. onCrStepChangegives the new index inevent.detailon every change.
If the user has asked their system to reduce motion, progress changes without any movement.
Accessibility
- The progress indicator is a group named by
label("Progress" by default, "Progression" in French). - Screen readers read the list of steps with their state ("completed", "current", "upcoming") and the current step has
aria-current="step"; the drawings (line, gauge, blocks…) are hidden from them. - Each step change is announced: "Step 2 of 4: Profile", then "All steps are completed.".
- If focus was in a step that gets hidden, it moves to the new step; if the button used disappears, it moves to the other button.
- The
pathbounce stops after three times: no endless motion.
API
Properties
| Property | Type | Default | Description |
|---|---|---|---|
current | number | 0 | Index de l'étape en cours (0 pour la première) ; vaut le nombre d'étapes quand tout est terminé. |
label | string | — | Nom de la progression, lu par les lecteurs d'écran (« Progress », ou « Progression » en français, par défaut). |
navigation | boolean | false | Ajoute les boutons « Précédent » et « Suivant » (« Terminer » à la dernière étape). |
variant | "blocks" | "gauge" | "line" | "number" | "path" | "timeline" | 'line' | Présentation : line (Bead Line), number (Big Number), path (Skill Path), blocks (Level Blocks), gauge (Gauge Arc) ou timeline (verticale). |
Events
| React | event.detail | Description |
|---|---|---|
onCrComplete | void | Émis quand la dernière étape est validée. |
onCrStepChange | number | Émis à chaque changement d'étape ; detail : l'index de la nouvelle étape. |
Slots
| Slot | Description |
|---|---|
| default | Les étapes cr-step. |
CSS parts
To style it from outside: cr-stepper::part(name) { … }
| Part | Description |
|---|---|
nav | Les boutons Précédent et Suivant. |
CrStep API
Properties
| Property | Type | Default | Description |
|---|---|---|---|
label (obligatoire) | string | — | Nom de l'étape. |
Slots
| Slot | Description |
|---|---|
| default | Le contenu de l'étape. |
CSS parts
To style it from outside: cr-step::part(name) { … }
| Part | Description |
|---|---|
content | Le contenu affiché. |