UI Toolbox logoUI Toolbox
Support

Wizard

A Wizard shows one WizardStep at a time, with a step list at the top, the step title and description, and Cancel, Back, Skip and Next (Finish on the last step) buttons.

A character wizard on its second step, Your world, with the first step done and Back and Next buttonsA character wizard on its second step, Your world, with the first step done and Back and Next buttons

Video tutorial: Wizard. All videos: Video tutorials.

<UIToolbox.Wizard
    name="setup"
    allow-step-clicking="true"
    finish-text="Complete Setup">
    <UIToolbox.WizardStep
        name="welcome"
        title="Welcome"
        description="This wizard sets up a user account." />
    <UIToolbox.WizardStep name="user" title="User">
        <ui:TextField name="username" label="User name" />
    </UIToolbox.WizardStep>
    <UIToolbox.WizardStep
        name="advanced"
        title="Advanced"
        can-skip="true" />
    <UIToolbox.WizardStep
        name="summary"
        title="Summary"
        can-go-back="false" />
</UIToolbox.Wizard>
wizard.GetStep("user").Validator = step =>
{
    if (step.Q<TextField>("username").value.Length > 0) return true;
    wizard.ShowValidationError("Enter a user name.",
        step.Q<TextField>("username"));
    return false;
};
wizard.GetStep("advanced").VisibilityCondition = () => expert.value;
expert.RegisterValueChangedCallback(_ => wizard.Refresh());
Member Description
WizardStep Title, Description (title, description) The page heading and the text under it. An empty title shows the step name; DisplayTitle gives the text that shows.
WizardStep.CanSkip (can-skip) Shows the Skip button on the step.
WizardStep.CanGoBack (can-go-back) False turns off Back and the step-list clicks to earlier steps on this step. The default is true.
WizardStep.Validator Returns false to stop Next, Finish and a forward step-list click. Call ShowValidationError in it to tell the user why. Give it the field with the error to put that field in the error state.
WizardStep.VisibilityCondition Returns false to leave the step out (a branch). Call Refresh when the condition changes.
WizardStep.IsCompleted True after Next, Skip or Finish leave the step.
ShowProgress, ShowStepNumbers, AllowStepClicking (show-progress, show-step-numbers, allow-step-clicking) The step list, the numbers in it (a check mark on a completed step), and clicks on it.
CancelText, BackText, SkipText, NextText, FinishText The button texts (cancel-text and so on).
Next(), Back(), Skip(), Finish() The button actions. Each returns false when the move is not allowed. Back does not validate.
CancelAsync(), CancelConfirmation The Cancel button. CancelAsync awaits CancelConfirmation, then sends Cancelled; it returns false when the confirmation says no. Null cancels at once. While a confirmation is open, another cancel does nothing.
GoToStep(name), Reset(), InsertStep(index, step), GetStep(name) Moves without a check; clears the completed marks and shows the first step; adds a step; finds a step.
Steps, VisibleSteps, CurrentStep, IsLastStep, ValidationError The state.
SaveState(), RestoreState(json) The current step and the completed steps as JSON. The fields in the steps are not saved.
StepChanged(from, to), StepCompleted(step), Completed(steps), Cancelled The events. Completed gets the visible steps.
ShowValidationError(message, field), ClearValidationError() Shows the error line, or the error state of a field; hides it again. The next move clears it too.
StepValidating(args) Comes before each move by Next, Back, Skip, Finish or a step-list click. args is a WizardStepValidatingEventArgs and has Step, Target (null for Finish), Direction (Forward, Backward or Skip) and IsFinish. Set Cancel to stop the move.
wizard.CancelConfirmation = async () =>
    await MessageBox.ShowAsync(this, "Discard the setup?", "Cancel",
        MessageBoxButtons.YesNo) == MessageBoxResult.Yes;
<tb:Window
    id="setup"
    title="Setup"
    width="520"
    height="400"
    enable-scrolling="false">
    <UIToolbox.Wizard style="flex-grow: 1;"> ... </UIToolbox.Wizard>
</tb:Window>
wizard.StepValidating += e =>
{
    if (e.Direction != WizardDirection.Backward || !unsavedChanges)
        return;
    e.Cancel = true;
    wizard.ShowValidationError("Save the changes first.");
};

Styling

Class Element
tb-wizard The wizard. It grows to fill its parent.
tb-wizard__steps The step list (a row with a bottom border).
tb-wizard__step An item in the step list (faded).
tb-wizard__step--current The item of the current step (not faded, accent number, bold title).
tb-wizard__step--completed The item of a completed step (not faded, accent check mark).
tb-wizard__step--clickable An item that a click can go to (accent title on hover).
tb-wizard__step-number The number or check mark circle (20 px).
tb-wizard__step-title The title in an item.
tb-wizard__title The page heading (15 px, bold).
tb-wizard__description The text under the heading (muted).
tb-wizard__content The area that holds the steps (grows, clips).
tb-wizard-step--enter-next, tb-wizard-step--enter-back The start of the step transition: 24 px to the right or the left, opacity 0. The wizard removes the class to play the transition.
tb-wizard-step--anim The transition on a step while it comes in: translate and opacity, --tb-animation-duration-fast, entrance easing.
tb-wizard__error The validation error (danger color).
tb-wizard__buttons The button row.
tb-wizard__button, tb-wizard__button--default The buttons and the Next/Finish button. The MessageBox button rules style them.

The WizardDemo scene shows a hero in steps with the step list, a new game with a check on each step, a branch and a question before a cancel, and a tutorial that skips a step and saves its place.