> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/powershell-universal/apps/components/navigation/stepper.md). Agents can also search and read this documentation through its [MCP server](https://docs.devolutions.net/~gitbook/mcp).

# Stepper

Build multi step wizards in PowerShell Universal apps with the Stepper component, including step validation, skipping, and vertical orientation.

**Steppers convey progress through numbered steps. It provides a wizard-like workflow.**

Steppers display progress through a sequence of logical and numbered steps. They may also be used for navigation. Steppers may display a transient feedback message after a step is saved. The stepper supports storing input data in the stepper context. It supports the following controls.

* [Autocomplete](https://docs.devolutions.net/powershell-universal/apps/components/inputs/automcomplete.md)
* [Checkbox](https://docs.devolutions.net/powershell-universal/apps/components/inputs/checkbox.md)
* [Date Picker](https://docs.devolutions.net/powershell-universal/apps/components/inputs/date-picker.md)
* [Radio](https://docs.devolutions.net/powershell-universal/apps/components/inputs/radio.md)
* [Select](https://docs.devolutions.net/powershell-universal/apps/components/inputs/select.md)
* [Slider](https://docs.devolutions.net/powershell-universal/apps/components/inputs/slider.md)
* [Switch](https://docs.devolutions.net/powershell-universal/apps/components/inputs/switch.md)
* [Textbox](https://docs.devolutions.net/powershell-universal/apps/components/inputs/textbox.md)
* [Time Picker](https://docs.devolutions.net/powershell-universal/apps/components/inputs/time-picker.md)
* [Upload](https://docs.devolutions.net/powershell-universal/apps/components/inputs/upload.md)

## Stepper

```powershell
New-UDStepper -Steps {
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 1" }
        New-UDTextbox -Id 'txtStep1' -Value $EventData.Context.txtStep1
    } -Label "Step 1"
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 2" }
        New-UDElement -tag 'div' -Content { "Previous data: $Body" }
        New-UDTextbox -Id 'txtStep2' -Value $EventData.Context.txtStep2
    } -Label "Step 2"
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 3" }
        New-UDElement -tag 'div' -Content { "Previous data: $Body" }
        New-UDTextbox -Id 'txtStep3' -Value $EventData.Context.txtStep3
    } -Label "Step 3"
} -OnFinish {
    New-UDTypography -Text 'Nice! You did it!' -Variant h3
    New-UDElement -Tag 'div' -Id 'result' -Content {$Body}
}
```

The $Body variable will contain a JSON string that contains the current state of the stepper. You will receive information about the fields that have been defined within the stepper and info about the current step that has been completed. The $Body JSON string will have the following format.

```javascript
{
    context: {
        txtStep1: "value1",
        txtStep2: "value2",
        txtStep3: "value3"
    },
    currentStep: 0
}
```

## Validating a Step

You can validate a step in a stepper by specifying the `OnValidateStep` parameter. The script block will receive a $Body variable with JSON that provides information about the current state of the stepper. You will need to return a validation result using `New-UDValidationResult` to specify whether the current step state is valid.

The JSON payload will have the following format. Note that steps are 0 indexed. If you want to validate the first step, check to make sure the step is 0.

```javascript
{
    context: {
        field1: "value1" 
    },
    currentStep: 0
}
```

You will have to convert the JSON string to an object to work with in PowerShell and then return the validation result.

```powershell
New-UDStepper -Steps {
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 1" }
        New-UDTextbox -Id 'txtStep1' -Value $EventData.Context.txtStep1
    } -Label "Step 1"
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 2" }
        New-UDElement -tag 'div' -Content { "Previous data: $Body" }
        New-UDTextbox -Id 'txtStep2' -Value $EventData.Context.txtStep2
    } -Label "Step 2"
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 3" }
        New-UDElement -tag 'div' -Content { "Previous data: $Body" }
        New-UDTextbox -Id 'txtStep3' -Value $EventData.Context.txtStep3
    } -Label "Step 3"
} -OnFinish {
    New-UDTypography -Text 'Nice! You did it!' -Variant h3
    New-UDElement -Tag 'div' -Id 'result' -Content {$Body}
} -OnValidateStep {
    $Context = $EventData
    if ($Context.CurrentStep -eq 0 -and $Context.Context.txtStep1 -eq 'bad')
    {
        New-UDValidationResult 
    }
    else
    {
        New-UDValidationResult -Valid 
    }
}
```

## Skipping Steps

You can direct the user to a particular step in the `OnValidateStep` event handler. Use the `New-UDValidationResult` `-ActiveStep` parameter to move the user to any step after clicking next. Step indices are 0 based.

This example moves the user to the last step after completing the first step.

```powershell
New-UDStepper -Steps {
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 1" }
        New-UDTextbox -Id 'txtStep1' -Value $EventData.Context.txtStep1
    } -Label "Step 1"
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 2" }
        New-UDElement -tag 'div' -Content { "Previous data: $Body" }
        New-UDTextbox -Id 'txtStep2' -Value $EventData.Context.txtStep2
    } -Label "Step 2"
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 3" }
        New-UDElement -tag 'div' -Content { "Previous data: $Body" }
        New-UDTextbox -Id 'txtStep3' -Value $EventData.Context.txtStep3
    } -Label "Step 3"
} -OnFinish {
    New-UDTypography -Text 'Nice! You did it!' -Variant h3
    New-UDElement -Tag 'div' -Id 'result' -Content {$Body}
} -OnValidateStep {
    $Context = $EventData
    if ($Context.CurrentStep -eq 0 -and $Context.Context.txtStep1 -eq 'bad')
    {
        New-UDValidationResult 
    }
    else
    {
        New-UDValidationResult -Valid -ActiveStep 2
    }
}
```

## Disable Previous Button

You can disable the previous button by using the `-DisablePrevious` parameter of `New-UDValidationResult` .

This example disables the previous step whenever the user moves forward in the stepper.

```powershell
New-UDStepper -Steps {
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 1" }
        New-UDTextbox -Id 'txtStep1' -Value $EventData.Context.txtStep1
    } -Label "Step 1"
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 2" }
        New-UDElement -tag 'div' -Content { "Previous data: $Body" }
        New-UDTextbox -Id 'txtStep2' -Value $EventData.Context.txtStep2
    } -Label "Step 2"
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 3" }
        New-UDElement -tag 'div' -Content { "Previous data: $Body" }
        New-UDTextbox -Id 'txtStep3' -Value $EventData.Context.txtStep3
    } -Label "Step 3"
} -OnFinish {
    New-UDTypography -Text 'Nice! You did it!' -Variant h3
    New-UDElement -Tag 'div' -Id 'result' -Content {$Body}
} -OnValidateStep {
    New-UDValidationResult -Valid -DisablePrevious
}
```

## Vertical Steppers

You can create a vertical stepper by setting the `-Orientation` parameter to vertical.

```powershell
New-UDStepper -Steps {
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 1" }
        New-UDTextbox -Id 'txtStep1' -Value $EventData.Context.txtStep1
    } -Label "Step 1"
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 2" }
        New-UDElement -tag 'div' -Content { "Previous data: $Body" }
        New-UDTextbox -Id 'txtStep2' -Value $EventData.Context.txtStep2
    } -Label "Step 2"
    New-UDStep -OnLoad {
        New-UDElement -tag 'div' -Content { "Step 3" }
        New-UDElement -tag 'div' -Content { "Previous data: $Body" }
        New-UDTextbox -Id 'txtStep3' -Value $EventData.Context.txtStep3
    } -Label "Step 3"
} -OnFinish {
    New-UDTypography -Text 'Nice! You did it!' -Variant h3
    New-UDElement -Tag 'div' -Id 'result' -Content {$Body}
} -Orientation 'vertical'
```

## Buttons and Behavior

* The stepper shows a **Back** button and a **Next** button. On the last step, the **Next** button shows the `-FinishButtonText` value (**Finish** by default) and runs `-OnFinish`. The output of `-OnFinish` replaces the stepper.
* When `-OnCancel` is set, the stepper also shows a **Cancel** button that runs this script block.
* The **Back** button is disabled on the first step, on a step created with `New-UDStep -DisablePrevious`, and after a validation result returned with `-DisablePrevious`.
* When `-OnValidateStep` returns a result that is not valid, the stepper stays on the current step, marks its label as an error and shows the `-ValidationError` message of `New-UDValidationResult` (default: `Form is invalid.`).
* With `-NonLinear`, the user can click a step label to go directly to that step.
* When the stepper has no steps, it shows the message `This stepper has no steps.`

## Parameters

### New-UDStepper

| Name             | Type        | Description                                                                                                               |
| ---------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------- |
| Id               | String      | The ID of the component. Defaults to a random GUID.                                                                       |
| Children         | ScriptBlock | Mandatory. The steps. Use `New-UDStep`. Alias: `Steps`.                                                                   |
| OnFinish         | Endpoint    | Mandatory. A script block to run when the user clicks the finish button on the last step.                                 |
| OnCancel         | Endpoint    | A script block to run when the user clicks the cancel button. The cancel button is only shown when this parameter is set. |
| OnValidateStep   | Endpoint    | A script block that validates the current step. It must return `New-UDValidationResult`.                                  |
| ActiveStep       | Int         | The index of the step shown first. Default: `0`.                                                                          |
| NonLinear        | Switch      | Lets the user go to steps out of order by clicking their labels.                                                          |
| AlternativeLabel | Switch      | Places each step label under the step number.                                                                             |
| Orientation      | String      | `horizontal` (default) or `vertical`.                                                                                     |
| NextButtonText   | String      | The text of the next button. Default: `Next`.                                                                             |
| BackButtonText   | String      | The text of the back button. Default: `Back`.                                                                             |
| FinishButtonText | String      | The text of the next button on the last step. Default: `Finish`.                                                          |
| CancelButtonText | String      | The text of the cancel button. Default: `Cancel`.                                                                         |
| ClassName        | String      | A CSS class to apply to the stepper.                                                                                      |
| Style            | Hashtable   | CSS styles to apply to the stepper.                                                                                       |
| Sx               | Hashtable   | Theme-aware styles to apply to the stepper.                                                                               |

### New-UDStep

| Name            | Type      | Description                                                                                                                                              |
| --------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Id              | String    | The ID of the step. Defaults to a random GUID.                                                                                                           |
| OnLoad          | Endpoint  | Mandatory. A script block that returns the content of the step. `$EventData.Context` contains the values of the fields entered so far. Alias: `Content`. |
| Label           | String    | The label of the step.                                                                                                                                   |
| Optional        | Switch    | Marks the step as optional. In PowerShell Universal 2026.3.5, the stepper does not display optional steps differently.                                   |
| DisablePrevious | Switch    | Disables the back button on this step.                                                                                                                   |
| Icon            | Object    | An icon to show instead of the step number: an icon name, or `New-UDIcon`. By default, the icon is shown in a colored circle.                            |
| RemoveIconStyle | Switch    | Removes the colored circle around the icon.                                                                                                              |
| IconStyle       | Hashtable | CSS styles for the icon container.                                                                                                                       |
| DarkIconStyle   | Hashtable | CSS styles for the icon container when the dark theme is used. Defaults to `-IconStyle`.                                                                 |

### New-UDValidationResult

| Name            | Type      | Description                                                                  |
| --------------- | --------- | ---------------------------------------------------------------------------- |
| Valid           | Switch    | The step is valid and the stepper moves to the next step.                    |
| ValidationError | String    | The message to show when the step is not valid. Default: `Form is invalid.`  |
| Context         | Hashtable | Field values to set in the stepper context. Stepper only.                    |
| DisablePrevious | Switch    | Disables the back button. Stepper only.                                      |
| ActiveStep      | Int       | The index of the step to show next. Default: `-1` (no change). Stepper only. |

## API

* [New-UDStepper](https://docs.devolutions.net/powershell-universal/powershell-commands/new-udstepper.md)
* [New-UDStep](https://docs.devolutions.net/powershell-universal/powershell-commands/new-udstep.md)
* [New-UDValidationResult](https://docs.devolutions.net/powershell-universal/powershell-commands/new-udvalidationresult.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.devolutions.net/powershell-universal/apps/components/navigation/stepper.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
