Documentation / Navigation & actions
Wizard
A multi-step wizard: a progress indicator (WizardSteps), one panel per step (WizardPanel) and the navigation buttons (WizardActions, WizardPrevious, WizardNext). Steps are declared in steps (title, description, icon, optional, disabled, error) and each sub-component reads the shared state.
Uncontrolled with defaultStep, controlled with step + onStepChange, which also receives the step being left and the direction. In linear mode (the default), only steps already reached can be clicked; linear={false} opens them all. On the last step, “next” calls onComplete. useWizard() gives access to the state and actions for custom controls. Client component ("use client").
Examples
Basic usage
The indicator, one panel per step and the default buttons, translated here.
import { Wizard, WizardActions, WizardNext, WizardPanel, WizardPrevious, WizardSteps, type WizardStepDefinition } from "@synertech/ui";
const steps: WizardStepDefinition[] = [
{ id: "compte", title: "Compte", description: "Vos identifiants" },
{ id: "profil", title: "Profil", description: "Qui êtes-vous ?" },
{ id: "equipe", title: "Équipe", description: "Invitez vos collègues", optional: true },
{ id: "recap", title: "Récapitulatif" },
];
export function Basic() {
return (
<Wizard steps={steps} onComplete={() => console.log("Inscription terminée")}>
<WizardSteps />
{steps.map((step, index) => (
<WizardPanel key={step.id} index={index}>
<p className="text-sm text-gray-600 dark:text-gray-400">
Contenu de l’étape « {step.title} ».
</p>
</WizardPanel>
))}
<WizardActions>
<WizardPrevious label="Précédent" />
<WizardNext label="Suivant" finishLabel="Terminer" />
</WizardActions>
</Wizard>
);
}On a phone
hideLabels="below-md" keeps the markers only under 768 px wide, where four steps and their titles no longer fit; above, the titles come back. Hidden, they are still the name of each step for a screen reader.
import { Wizard, WizardSteps, type WizardStepDefinition } from "@synertech/ui";
const steps: WizardStepDefinition[] = [
{ id: "compte", title: "Compte", description: "Vos identifiants" },
{ id: "profil", title: "Profil", description: "Qui êtes-vous ?" },
{ id: "equipe", title: "Équipe", description: "Invitez vos collègues", optional: true },
{ id: "recap", title: "Récapitulatif" },
];
export function OnAPhone() {
return (
<Wizard steps={steps} defaultStep={1} linear={false}>
<WizardSteps hideLabels="below-md" />
<p className="mt-4 text-sm text-gray-600 dark:text-gray-400">
Réduisez la fenêtre : sous 768 px, il ne reste que les repères.
</p>
</Wizard>
);
}Styles and orientation
variant="dots" reduces the markers to dots; orientation="vertical" stacks the steps.
import { Wizard, WizardSteps, type WizardStepDefinition } from "@synertech/ui";
const steps: WizardStepDefinition[] = [
{ id: "compte", title: "Compte", description: "Vos identifiants" },
{ id: "profil", title: "Profil", description: "Qui êtes-vous ?" },
{ id: "equipe", title: "Équipe", description: "Invitez vos collègues", optional: true },
{ id: "recap", title: "Récapitulatif" },
];
export function Variants() {
return (
<div className="grid gap-8 md:grid-cols-2">
<Wizard steps={steps} defaultStep={1} variant="dots" color="success" size="sm">
<WizardSteps />
</Wizard>
<Wizard steps={steps} defaultStep={2} orientation="vertical" color="secondary">
<WizardSteps />
</Wizard>
</div>
);
}Free navigation and a step in error
linear={false} makes every step clickable; error and disabled are set per step.
import { Wizard, WizardContent, WizardSteps, type WizardStepDefinition } from "@synertech/ui";
const steps: WizardStepDefinition[] = [
{ id: "compte", title: "Compte", description: "Vos identifiants" },
{ id: "profil", title: "Profil", description: "Qui êtes-vous ?" },
{ id: "equipe", title: "Équipe", description: "Invitez vos collègues", optional: true },
{ id: "recap", title: "Récapitulatif" },
];
export function NonLinear() {
const reviewSteps: WizardStepDefinition[] = [
{ title: "Informations" },
{ title: "Pièces jointes", error: true, description: "2 fichiers manquants" },
{ title: "Signature", disabled: true },
{ title: "Envoi" },
];
return (
<Wizard steps={reviewSteps} linear={false} variant="simple">
<WizardSteps />
<WizardContent>
{({ activeStep, steps: all }) => (
<p className="text-sm">Étape affichée : {all[activeStep].title}</p>
)}
</WizardContent>
</Wizard>
);
}Custom controls
useWizard() exposes the active step and the actions to any child of the Wizard.
import { Button, Wizard, WizardSteps, useWizard, type WizardStepDefinition } from "@synertech/ui";
const steps: WizardStepDefinition[] = [
{ id: "compte", title: "Compte", description: "Vos identifiants" },
{ id: "profil", title: "Profil", description: "Qui êtes-vous ?" },
{ id: "equipe", title: "Équipe", description: "Invitez vos collègues", optional: true },
{ id: "recap", title: "Récapitulatif" },
];
function StepCounter() {
const { activeStep, totalSteps, goBack, goNext, isFirstStep, isLastStep } = useWizard();
return (
<div className="flex items-center justify-between">
<Button size="sm" onClick={goBack} disabled={isFirstStep}>
Retour
</Button>
<span className="text-sm text-gray-600 dark:text-gray-400">
Étape {activeStep + 1} sur {totalSteps}
</span>
<Button size="sm" onClick={goNext}>
{isLastStep ? "Valider" : "Continuer"}
</Button>
</div>
);
}
export function CustomControls() {
return (
<Wizard steps={steps} onComplete={() => console.log("Validé")}>
<WizardSteps hideLabels />
<StepCounter />
</Wizard>
);
}Form with validation
In controlled mode, onClick on WizardNext can block moving forward with preventDefault().
import { useState } from "react";
import { Input, Wizard, WizardActions, WizardNext, WizardPanel, WizardPrevious, WizardSteps, type WizardStepDefinition } from "@synertech/ui";
const steps: WizardStepDefinition[] = [
{ id: "compte", title: "Compte", description: "Vos identifiants" },
{ id: "profil", title: "Profil", description: "Qui êtes-vous ?" },
{ id: "equipe", title: "Équipe", description: "Invitez vos collègues", optional: true },
{ id: "recap", title: "Récapitulatif" },
];
export function WithValidation() {
const [step, setStep] = useState(0);
const [email, setEmail] = useState("");
const invalid = step === 0 && !email.includes("@");
return (
<Wizard
steps={steps}
step={step}
onStepChange={(next) => setStep(next)}
onComplete={() => console.log(email)}
>
<WizardSteps />
<WizardPanel index={0}>
<Input
label="Adresse e-mail"
type="email"
value={email}
onChange={(event) => setEmail(event.target.value)}
/>
{invalid && email && (
<p className="mt-1 text-sm text-red-600">Saisissez une adresse valide.</p>
)}
</WizardPanel>
<WizardPanel index={1}>Complétez votre profil.</WizardPanel>
<WizardPanel index={2}>Invitez votre équipe (facultatif).</WizardPanel>
<WizardPanel index={3}>Tout est prêt pour {email}.</WizardPanel>
<WizardActions>
<WizardPrevious label="Précédent" />
<WizardNext
label="Suivant"
finishLabel="Créer le compte"
onClick={(event) => {
if (invalid) event.preventDefault();
}}
/>
</WizardActions>
</Wizard>
);
}API reference
Components
import { Wizard } from "@synertech/ui";Props — WizardProps
| Prop | Type | Default | Description |
|---|---|---|---|
children• |
ReactNode |
— | |
steps• |
WizardStepDefinition[] |
— | Ordered list of steps that drives the indicator and navigation bounds |
className |
string |
— | Additional class names on the root element |
color |
WizardColor |
"primary" |
Accent color |
defaultStep |
number |
0 |
Default active step index for uncontrolled mode |
linear |
boolean |
true |
When true (default), only reached steps can be clicked |
onComplete |
() => void |
— | Called when "Next" is pressed on the last step, or on a step that only disabled steps follow |
onStepChange |
(step: number, meta: WizardStepChangeMeta) => void |
— | Called whenever the active step changes |
orientation |
WizardOrientation |
"horizontal" |
Indicator orientation |
size |
WizardSize |
"md" |
Size |
step |
number |
— | Controlled active step index |
variant |
WizardVariant |
"default" |
Indicator visual variant |
import { WizardActions } from "@synertech/ui";Props — WizardActionsProps
| Prop | Type | Default | Description |
|---|---|---|---|
align |
"between" | "start" | "center" | "end" |
"between" |
Horizontal alignment of the controls |
children |
ReactNode |
— | Custom controls. Defaults to Previous + Next when omitted. |
className |
string |
— |
import { WizardContent } from "@synertech/ui";Props — WizardContentProps
| Prop | Type | Default | Description |
|---|---|---|---|
children• |
ReactNode | ((wizard: WizardContextValue) => ReactNode) |
— | Static content or a render-prop receiving the wizard state |
className |
string |
— |
import { WizardNext } from "@synertech/ui";Props — WizardNextProps
| Prop | Type | Default | Description |
|---|---|---|---|
children |
ReactNode |
— | |
finishLabel |
ReactNode |
— | Button text on the final step |
label |
ReactNode |
— | Button text on non-final steps |
+ 288 inherited native attributes from ButtonHTMLAttributes, HTMLAttributes, AriaAttributes (className, id, aria-*, event handlers…).
import { WizardPanel } from "@synertech/ui";Props — WizardPanelProps
| Prop | Type | Default | Description |
|---|---|---|---|
children• |
ReactNode |
— | |
index• |
number |
— | Step index this panel belongs to |
className |
string |
— | |
keepMounted |
boolean |
false |
Keep the panel mounted (hidden) when inactive instead of unmounting |
import { WizardPrevious } from "@synertech/ui";Props — WizardPreviousProps
| Prop | Type | Default | Description |
|---|---|---|---|
children |
ReactNode |
— | |
label |
ReactNode |
— | Button text (used when no children are provided) |
+ 288 inherited native attributes from ButtonHTMLAttributes, HTMLAttributes, AriaAttributes (className, id, aria-*, event handlers…).
import { WizardSteps } from "@synertech/ui";Props — WizardStepsProps
| Prop | Type | Default | Description |
|---|---|---|---|
className |
string |
— | Additional class names on the indicator list |
hideConnector |
boolean |
false |
Hide the connector lines between steps |
hideLabels |
boolean | keyof typeof hiddenLabelClasses |
false |
Hide the titles and descriptions, markers only: |
optionalLabel |
string |
— | Hint after the title of an optional step. Defaults to the |
Hooks
Access the surrounding Wizard state. Useful for building custom controls. Throws when used outside of a <Wizard> provider.
import { useWizard } from "@synertech/ui";useWizard(): WizardContextValueTypes
WizardContextValue
Interfaceinterface WizardContextValue| Field | Type | Default | Description |
|---|---|---|---|
activeStep• |
number |
— | |
color• |
WizardColor |
— | |
getStepStatus• |
(index: number) => WizardStepStatus |
— | Resolve the visual status of a given step |
goBack• |
() => void |
— | Go back to the previous step that is not disabled |
goNext• |
() => void |
— | Advance to the next step that is not disabled, or call onComplete when there is none |
goToStep• |
(index: number) => void |
— | Navigate to a specific step (respects accessibility rules) |
isFirstStep• |
boolean |
— | No step before this one can be entered: Previous has nowhere to go. |
isLastStep• |
boolean |
— | No step after this one can be entered: Next completes the wizard. |
isStepAccessible• |
(index: number) => boolean |
— | Whether a step can be navigated to via click |
linear• |
boolean |
— | |
orientation• |
WizardOrientation |
— | |
size• |
WizardSize |
— | |
steps• |
WizardStepDefinition[] |
— | |
totalSteps• |
number |
— | |
variant• |
WizardVariant |
— |
WizardStepChangeMeta
Interfaceinterface WizardStepChangeMeta| Field | Type | Default | Description |
|---|---|---|---|
direction• |
WizardDirection |
— | Navigation direction |
previous• |
number |
— | The step index we navigated away from |
WizardStepDefinition
Interfaceinterface WizardStepDefinition| Field | Type | Default | Description |
|---|---|---|---|
title• |
ReactNode |
— | Step title shown in the indicator |
description |
ReactNode |
— | Optional secondary line under the title |
disabled |
boolean |
— | Disable navigation to this step |
error |
boolean |
— | Force the error visual state on this step |
icon |
ReactNode |
— | Custom marker content (replaces the step number) |
id |
string |
— | Stable identifier (used as React key). Falls back to the index. |
optional |
boolean |
— | Mark the step as optional (adds an "(optional)" hint) |
WizardColor
Typetype WizardColor = "primary" | "secondary" | "success" | "warning" | "error"WizardDirection
Typetype WizardDirection = "forward" | "backward" | "jump"type WizardOrientation = "horizontal" | "vertical"WizardSize
Typetype WizardSize = "sm" | "md" | "lg"WizardStepStatus
Typetype WizardStepStatus = "upcoming" | "active" | "completed" | "error"WizardVariant
Typetype WizardVariant = "default" | "dots" | "simple"