VDT.Core.Blazor.Wizard
6.0.1
See the version list below for details.
dotnet add package VDT.Core.Blazor.Wizard --version 6.0.1
NuGet\Install-Package VDT.Core.Blazor.Wizard -Version 6.0.1
<PackageReference Include="VDT.Core.Blazor.Wizard" Version="6.0.1" />
<PackageVersion Include="VDT.Core.Blazor.Wizard" Version="6.0.1" />
<PackageReference Include="VDT.Core.Blazor.Wizard" />
paket add VDT.Core.Blazor.Wizard --version 6.0.1
#r "nuget: VDT.Core.Blazor.Wizard, 6.0.1"
#:package VDT.Core.Blazor.Wizard@6.0.1
#addin nuget:?package=VDT.Core.Blazor.Wizard&version=6.0.1
#tool nuget:?package=VDT.Core.Blazor.Wizard&version=6.0.1
VDT.Core.Blazor.Wizard
Blazor component that helps you create wizard components with sequential steps, forward/back navigation, conditional completion of steps, step- and wizard-level events, and more
Features
- Fully customizable layout
- Events for starting, stopping and completing the wizard
- Steps completed only on your own conditions
- Events for initializing and attempted competion of steps
- Optional back navigation and cancelling
Example
<div>
<button @onclick="async () => await Wizard.Start()" class="btn btn-primary">Start wizard</button>
<button @onclick="() => Wizard.Stop()" class="btn btn-secondary">Stop wizard</button>
</div>
<Wizard @ref="Wizard"
OnStart="Start"
OnStop="Stop"
OnFinish="Finish"
ContainerClass="wizard"
TitleContainerClass="wizard-title"
StepTitleContainerClass="wizard-steps"
StepTitleClass="wizard-step"
ActiveStepTitleClass="active"
AllowCancel="true"
AllowPrevious="true"
ButtonContainerClass="wizard-buttons"
ButtonClass="wizard-button"
ButtonCancelClass="wizard-button-secondary"
ButtonCancelText="Stop"
ButtonPreviousClass="wizard-button-secondary"
ButtonPreviousText="<< Prev"
ButtonFinishClass="wizard-button-primary"
ButtonFinishText="Complete"
ButtonNextClass="wizard-button-primary"
ButtonNextText="Next >>"
ContentContainerClass="wizard-body">
<TitleContent>
<h3>Wizard title</h3>
</TitleContent>
<Steps>
<WizardStep OnInitialize="args => InitializeStep(args, 1)" OnTryComplete="args => TryCompleteStep(args, 1)" Title="The first step">
Test step 1
</WizardStep>
<WizardStep OnInitialize="args => InitializeStep(args, 2)" OnTryComplete="args => TryCompleteStep(args, 2)" Title="Another">
<div class="form-check">
<input id="goNext" type="checkbox" @bind="GoNext" class="form-check-input" />
<label for="goNext" class="form-check-label">Go next?</label>
</div>
<div>
Test step 2
</div>
</WizardStep>
<WizardStep OnInitialize="args => InitializeStep(args, 3)" OnTryComplete="args => TryCompleteStep(args, 3)" Title="Summary">
Test step 3
</WizardStep>
</Steps>
</Wizard>
<pre>
@StepData
</pre>
@code {
public Wizard Wizard { get; set; }
public bool GoNext { get; set; } = true;
public string StepData = string.Empty;
public void Start(WizardStartedEventArgs args) {
StepData += $"{nameof(Start)} wizard{Environment.NewLine}";
}
public void Stop(WizardStoppedEventArgs args) {
StepData += $"{nameof(Stop)} wizard{Environment.NewLine}";
}
public void Finish(WizardFinishedEventArgs args) {
StepData += $"{nameof(Finish)} wizard{Environment.NewLine}";
}
public void InitializeStep(WizardStepInitializedEventArgs args, int step) {
StepData += $"{nameof(InitializeStep)} step {step}{Environment.NewLine}";
GoNext = true;
}
public void TryCompleteStep(WizardStepAttemptedCompleteEventArgs args, int step) {
StepData += $"{nameof(TryCompleteStep)} step {step}{Environment.NewLine}";
args.IsCancelled = !GoNext;
}
}
CSS class properties
ContainerClassgets applied to adivsurrounding the entire wizard when using the default layoutTitleContainerClassgets applied to adivsurrounding the title content when using the default layoutStepTitleContainerClassgets applied to adivsurrounding the step titles when using the default layoutStepTitleClassgets applied to the step titledivsActiveStepTitleClassgets applied to the active step titledivButtonContainerClassgets applied to adivsurrounding the navigation buttons when using the default layoutButtonClassgets applied to all navigation buttonsButtonCancelClassgets applied to the cancel buttonButtonPreviousClassgets applied to the previous buttonButtonNextClassgets applied to the next buttonButtonFinishClassgets applied to the finish buttonContentContainerClassgets applied to adivsurrounding the content of the currently active step when using the default layout
Events
You can subscribe to several events during the wizard's life cycle; most are informational only but some allow you to manipulate the wizard's behaviour.
- The
Wizard.OnStartevent fires when the wizard is started. - The
Wizard.OnStopevent fires when the wizard is stopped. - The
Wizard.OnFinishevent fires when the wizard is finished because all steps of the wizard have been completed. - The
WizardStep.OnInitializeevent fires when a step is rendered. - The
WizardStep.OnTryCompleteevent fires when a step is completed by clicking the Next button. The providedWizardStepAttemptedCompleteEventArgslets you see if the step has been previously completed and lets you cancel completion of a step.
Custom layout
If the default wizard layout does not suffice, it's easy to customize the layout by using the Layout renderfragment and the various renderfragments found on
the context provided by it. If you provide a layout template the default container elements will not be used and their CSS classes will not be applied, but
any properties for specific renderfragments for buttons or other common elements, such as CSS, titles and the various allow options will still be applied.
Renderfragments
context.DefaultLayoutrenders the wizard title contentcontext.Titlerenders the wizard title contentcontext.StepTitlesrenders the wizard step titlescontext.Buttonsrenders the wizard cancel, previous, next and finish buttons if they are available and enabledcontext.ButtonCancelrenders the wizard cancel button if enabledcontext.ButtonPreviousrenders the wizard previous button if enabled and there is a previous stepcontext.ButtonNextrenders the wizard next button if there is a next stepcontext.ButtonFinishrenders the wizard finish button if this is the final stepcontext.ActiveStepContentrenders the wizard active step content
For further customization, you can create a layout without using any renderfragments, instead using only properties and methods of the wizard that can be accessed via <code>context.Wizard</code>.
Wizard properties
This does not list Blazor parameters such as button texts or any of the CSS classes.
IsActiveindicates whether or not the wizard is currently activeActiveStepIndexis the index of the currently active step if the wizard is active, otherwisenullActiveStepis the currently active step if the wizard is active, otherwisenullIsFirstStepActiveindicates if the first step in the wizard is the currently active oneIsLastStepActiveindicates if the last step in the wizard is the currently active oneAllStepsreturns all available wizard steps in order of display
Wizard methods
Start()opens the wizard at the first step if it's not currently activeStop()closes and reset the wizard if it's currently activeGoToPreviousStep()goes to the previous step in this wizard if it is active and it's not on the first stepTryCompleteStep()attempts to complete the current step, then either move to the next step or complete the wizardGoToStep(...)navigates to a specific step in the wizard if it is active, after optionally attempting to complete the currently active step- Navigating to the step after the last available step completes and resets the wizard
- Available overloads:
GoToStep(WizardStep step, bool tryCompleteStep)GoToStep(int stepIndex, bool tryCompleteStep)GoToStep(StepIndexProvider stepIndexProvider, bool tryCompleteStep)
Wizard step properties
This does not list Blazor parameters such as Title.
IsActiveindicates whether or not the wizard step is currently activeIsCompletedindicates whether or not this step has been previously completed; resets tofalsewhen the wizard is closed
Example
This example wizard does not use any of the renderfragments, instead showing how to create a completely new layout with the same functionality and added navigation and indication for completed steps.
<Wizard @ref="Wizard">
<TitleContent>
<h2>Wizard title</h2>
</TitleContent>
<Layout>
<div class="card">
<div class="card-header">
@context.Title
</div>
<div>
<div class="d-flex align-items-stretch">
<div class="flex-grow-0 border-end bg-light px-3 py-2">
@foreach (var step in context.Wizard.AllSteps) {
<div class="me-3">
@if (step.IsActive) {
<span class="fw-bold">@step.Title</span>
}
else if (step.IsCompleted) {
<button class="btn btn-link p-0 align-baseline" @onclick="() => context.Wizard.GoToStep(step, false)">@step.Title</button>
}
else {
<span>@step.Title</span>
}
@if (step.IsCompleted) {
<span class="text-success fw-bold ps-1">✓</span>
}
</div>
}
</div>
<div class="flex-grow-1 px-3 py-2">
@context.ActiveStepContent
</div>
</div>
</div>
<div class="card-footer d-flex">
<div class="flex-grow-1">
<button class="btn btn-secondary" @onclick="context.Wizard.Stop">Stop</button>
</div>
<div class="flex-grow-0 btn-group">
@if (!context.Wizard.IsFirstStepActive) {
<button class="btn btn-secondary" @onclick="context.Wizard.GoToPreviousStep"><< Prev</button>
}
@if (context.Wizard.IsLastStepActive){
<button class="btn btn-primary" @onclick="context.Wizard.TryCompleteStep">Complete</button>
}
else {
<button class="btn btn-primary" @onclick="context.Wizard.TryCompleteStep">Next >></button>
}
</div>
</div>
</div>
</Layout>
<Steps>
<WizardStep Title="Introduction">
<p>
This is an example wizard with a custom layout. Please click Next to continue.
</p>
</WizardStep>
<WizardStep Title="Your step here">
<p>
This is the second step in this wizard. Please click Next to continue.
</p>
</WizardStep>
<WizardStep Title="Summary">
<p>
Please click Complete to finish the wizard.
</p>
</WizardStep>
</Steps>
</Wizard>
@code {
private Wizard? Wizard { get; set; }
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.AspNetCore.Components.Web (>= 10.0.0)
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.0)
-
net9.0
- Microsoft.AspNetCore.Components.Web (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
- Updated documentation and examples