# Getting Started with the Stepper

This tutorial explains how to set up a basic Telerik UI for ASP.NET Core Stepper and highlights the major steps in the configuration of the component.

You will initialize a Stepper control with predefined items and icons. Next, you will handle some of the Stepper events. Finally, you can run the sample code in [Telerik REPL](https://netcorerepl.telerik.com/) and continue exploring the components.

![Sample Telerik UI for ASP.NET Core Stepper](https://www.telerik.com/aspnet-core-ui/documentation/assets/8eb157fab59832c4e5e602defe0e07f0/stepper-getting-started.png)

## Prerequisites

To successfully complete the tutorial, you need a project that is already configured to use the Telerik UI for ASP.NET Core components:

* You can use the [Telerik REPL](https://netcorerepl.telerik.com/) playground and skip installing the components on your system and configuring a project.

* You can prepare a Visual Studio project by following the following guide:

  * Creating a new pre-configured project for the Telerik UI for ASP.NET Core components from [a project template](https://www.telerik.com/aspnet-core-ui/documentation/vs-integration/new-project-wizard).

## 1. Prepare the CSHTML File

The first step is to add the required directives at the top of the `.cshtml` document:

* To use the Telerik UI for ASP.NET Core HtmlHelpers:

  ```cshtml
  @using Kendo.Mvc.UI
  ```

* To use the Telerik UI for ASP.NET Core TagHelpers:

  ```cshtml
  @addTagHelper *, Kendo.Mvc
  ```

Optionally, you can structure the document by adding the desired HTML elements like headings, divs, paragraphs, and apply some basic styles.

## 2. Initialize the Stepper

Use the Stepper HtmlHelper or TagHelper to add the component to a page:

* The `Name()` configuration method is mandatory as its value is used for the `id` of the Stepper element.

* The `Items()` configuration method lets you add the desired Stepper items.

* The `Icon()` option of the Stepper individual items can be used to set the desired icon for the step.

```Razor HtmlHelper
    @using Kendo.Mvc.UI

    @(Html.Kendo().Stepper()
        .Name("stepper")
        .Steps(s =>
        {
            s.Add().Label("Home").Icon("home");
            s.Add().Label("Settings").Icon("gear");
            s.Add().Label("Attachments").Icon("paperclip");
            s.Add().Label("Save").Icon("save");
        })
    )
```

```Razor TagHelper
    @addTagHelper *, Kendo.Mvc

    <kendo-stepper name="stepper">
        <steps>
            <step icon="home" label="Home">
            </step>
            <step icon="gear" label="Settings">
            </step>
            <step icon="paperclip" label="Attachments">
            </step>
            <step icon="save" label="Save">
            </step>
        </steps>
    </kendo-stepper>    
```

## 4. Handle the Stepper Events

The Stepper [exposes various events](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/steppereventbuilder) that you can handle and further customize the functionality of the component. In this tutorial, you will use the `Activate` and `Select` events of the Stepper.

```Razor HtmlHelper
    @using Kendo.Mvc.UI

     @(Html.Kendo().Stepper()
        .Name("stepper")
        .Steps(s =>
        {
            s.Add().Label("Home").Icon("home");
            s.Add().Label("Settings").Icon("gear");
            s.Add().Label("Attachments").Icon("paperclip");
            s.Add().Label("Save").Icon("save");
        })
        .Events(events => events.Activate("onActivate").Select("onSelect"))
    )

<script>
    function onActivate(e) {
        console.log("Activated: " + e.step.options.label);
    }

    function onSelect(e) {
        console.log("Selected: " + e.step.options.label);
    }
</script>
```

```Razor TagHelper
    @addTagHelper *, Kendo.Mvc

    <kendo-stepper name="stepper" on-activate="onActivate" on-select="onSelect">
        <steps>
            <step icon="home" label="Home">
            </step>
            <step icon="gear" label="Settings">
            </step>
            <step icon="paperclip" label="Attachments">
            </step>
            <step icon="save" label="Save">
            </step>
        </steps>
    </kendo-stepper>

<script>
    function onActivate(e) {
        console.log("Activated: " + e.step.options.label);
    }

    function onSelect(e) {
        console.log("Selected: " + e.step.options.label);
    }
</script>
```

For more examples, refer to the [demo on using the events of the Stepper](https://demos.telerik.com/aspnet-core/stepper/events).

## 5. (Optional) Reference Existing Stepper Instances

To use the client-side API of the Stepper and build on top of its initial configuration, you need a reference to the Stepper instance. Once you get a valid reference, you can call the respective API methods:

1. Use the `.Name()` (id attribute) of the component instance to get a reference.

   ```JS script
   <script>
       var stepperReference = $("#Stepper").data("kendoStepper"); // stepperReference is a reference to the existing instance of the helper.
   </script>
   ```

2. Use the [Stepper client-side API](https://docs.telerik.com/kendo-ui/api/ui/stepper#methods) to control the behavior of the widget. In this example, you will use the `next` method to selects the step which is immediately after the currently selected step.

   ```JS script
   <script>
       $(document).ready(function () {
           var stepperReference = $("#Stepper").data("kendoStepper");

           stepperReference.next();
       })
   </script>
   ```

For more information on referencing specific helper instances, see the [Methods and Events](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/helper-basics/events-and-methods) article.

## Explore this Tutorial in REPL

You can continue experimenting with the code sample above by running it in the Telerik REPL server playground:

* [Sample code with the Stepper HtmlHelper](https://netcorerepl.telerik.com/wyabYrGF14Wl1PNC23)
* [Sample code with the Stepper TagHelper](https://netcorerepl.telerik.com/QSOlOLmv15y0snya08)

## Next Steps

* [Icons](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/navigation/stepper/icons)
* [Steps](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/navigation/stepper/steps)

## See Also

* [Using the API of the Stepper for ASP.NET Core (Demo)](https://demos.telerik.com/aspnet-core/stepper/api)
* [Client-Side API of the Stepper](https://docs.telerik.com/kendo-ui/api/ui/stepper)
* [Server-Side API of the Stepper](https://www.telerik.com/aspnet-core-ui/documentation/api/stepper)
* [Knowledge Base Section](https://www.telerik.com/aspnet-core-ui/documentation/knowledge-base)
