Synertech Web/ui v0.57.5 Site Storybook

Documentation / Navigation & actions

Wizard

Client@synertech/uiOpen in Storybook

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.

Open in a tab
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.

Open in a tab
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.

Open in a tab
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.

Open in a tab
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.

Open in a tab
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().

Open in a tab
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

Wizard

ComponentClient
import { Wizard } from "@synertech/ui";

Props — WizardProps

PropTypeDefaultDescription
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

WizardActions

ComponentClient
import { WizardActions } from "@synertech/ui";

Props — WizardActionsProps

PropTypeDefaultDescription
align "between" | "start" | "center" | "end" "between"

Horizontal alignment of the controls

children ReactNode —

Custom controls. Defaults to Previous + Next when omitted.

className string —

WizardContent

ComponentClient
import { WizardContent } from "@synertech/ui";

Props — WizardContentProps

PropTypeDefaultDescription
children• ReactNode | ((wizard: WizardContextValue) => ReactNode) —

Static content or a render-prop receiving the wizard state

className string —

WizardNext

ComponentClient
import { WizardNext } from "@synertech/ui";

Props — WizardNextProps

PropTypeDefaultDescription
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…).

WizardPanel

ComponentClient
import { WizardPanel } from "@synertech/ui";

Props — WizardPanelProps

PropTypeDefaultDescription
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

WizardPrevious

ComponentClient
import { WizardPrevious } from "@synertech/ui";

Props — WizardPreviousProps

PropTypeDefaultDescription
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…).

WizardSteps

ComponentClient
import { WizardSteps } from "@synertech/ui";

Props — WizardStepsProps

PropTypeDefaultDescription
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: true at every width, a breakpoint below it only ("below-md": under 768px, where four labelled steps no longer fit a phone). A hidden label is still read by a screen reader: it stays the name of its step.

optionalLabel string —

Hint after the title of an optional step. Defaults to the wizardOptional label.

Hooks

useWizard

HookClient

Access the surrounding Wizard state. Useful for building custom controls. Throws when used outside of a <Wizard> provider.

import { useWizard } from "@synertech/ui";
useWizard(): WizardContextValue

Types

FieldTypeDefaultDescription
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 —
FieldTypeDefaultDescription
direction• WizardDirection —

Navigation direction

previous• number —

The step index we navigated away from

FieldTypeDefaultDescription
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)

type WizardColor = "primary" | "secondary" | "success" | "warning" | "error"
type WizardDirection = "forward" | "backward" | "jump"
type WizardOrientation = "horizontal" | "vertical"
type WizardSize = "sm" | "md" | "lg"
type WizardStepStatus = "upcoming" | "active" | "completed" | "error"
type WizardVariant = "default" | "dots" | "simple"