# Getting Started with the TabStrip

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

You will initialize a TabStrip component with several items and a basic content definition. 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 TabStrip](https://www.telerik.com/aspnet-core-ui/documentation/assets/676d160903cc85279f577f97de874501/tabstrip-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 others.

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

    <h4>TabStrip with cities</h4>
    <div>

    </div>
```

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

    <h4>TabStrip with cities</h4>
    <div>

    </div>
```

## 2. Initialize the TabStrip

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

* The `Name()` configuration method is mandatory as its value is used for the `id` and the name attributes of the TabStrip element.
* The `Selected()` configuration of a TabStrip's item specifies which tab is selected initially.
* The `Image()` property of a TabStrip's item determines the icon or logo path in front of its text.

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

<h4>TabStrip with cities</h4>
<div>
@(Html.Kendo().TabStrip()
    .Name("tabstrip")
    .Items(tabstrip =>
    {
        tabstrip.Add().Text("Paris")
            .Selected(true)
            .ImageUrl(Url.Content("https://demos.telerik.com/aspnet-core/shared/icons/16/photo.png"))
            .Content(@<text>
            <div class="weather">
                <h2>17<span>ºC</span></h2>
                <p>Rainy weather in Paris.</p>
            </div>
            <span class="rainy"> </span>
            </text>);

        tabstrip.Add().Text("New York")
            .ImageUrl(Url.Content("https://demos.telerik.com/aspnet-core/shared/icons/16/star.png"))
            .Content(@<text>
            <div class="weather">
                <h2>29<span>ºC</span></h2>
                <p>Sunny weather in New York.</p>
            </div>
            <span class="sunny"> </span>
            </text>);
    })
)
</div>
```

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

<h4>TabStrip with cities</h4>
<div>
    <kendo-tabstrip name="tabstrip">
        <items>
            <tabstrip-item text="Paris" selected="true" 
            image-url="@Url.Content("https://demos.telerik.com/aspnet-core/shared/icons/16/photo.png")">
                <content>
                    <div class="weather">
                        <h2>17<span>&ordm;C</span></h2>
                        <p>Rainy weather in Paris.</p>
                    </div>
                    <span class="rainy">&nbsp;</span>
                </content>
            </tabstrip-item>
            <tabstrip-item text="New York" 
            image-url="@Url.Content("https://demos.telerik.com/aspnet-core/shared/icons/16/star.png")">
                <content>
                    <div class="weather">
                        <h2>29<span>&ordm;C</span></h2>
                        <p>Sunny weather in New York.</p>
                    </div>
                    <span class="sunny">&nbsp;</span>
                </content>
            </tabstrip-item>
        </items>
    </kendo-tabstrip>
</div>
```

## 3. Setting the Tab Position

The next step is to demonstrate how you can set the `TabPosition()` option which allows you to dictate where the tabs are rendered. The default setting is `Top`, but you can also use `Left`, `Bottom`, etc.

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

<h4>TabStrip with cities</h4>
<div>
@(Html.Kendo().TabStrip()
    .Name("tabstrip")
    .TabPosition(TabStripTabPosition.Top)
    .Items(tabstrip =>
    {
        tabstrip.Add().Text("Paris")
            .Selected(true)
            .ImageUrl(Url.Content("https://demos.telerik.com/aspnet-core/shared/icons/16/photo.png"))
            .Content(@<text>
            <div class="weather">
                <h2>17<span>ºC</span></h2>
                <p>Rainy weather in Paris.</p>
            </div>
            <span class="rainy"> </span>
            </text>);

        tabstrip.Add().Text("New York")
            .ImageUrl(Url.Content("https://demos.telerik.com/aspnet-core/shared/icons/16/star.png"))
            .Content(@<text>
            <div class="weather">
                <h2>29<span>ºC</span></h2>
                <p>Sunny weather in New York.</p>
            </div>
            <span class="sunny"> </span>
            </text>);
    })
)
</div>
```

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

<h4>TabStrip with cities</h4>
<div>
    <kendo-tabstrip name="tabstrip" tab-position="top">
        <items>
            <tabstrip-item text="Paris" selected="true" 
            image-url="@Url.Content("https://demos.telerik.com/aspnet-core/shared/icons/16/photo.png")">
                <content>
                    <div class="weather">
                        <h2>17<span>&ordm;C</span></h2>
                        <p>Rainy weather in Paris.</p>
                    </div>
                    <span class="rainy">&nbsp;</span>
                </content>
            </tabstrip-item>
            <tabstrip-item text="New York" 
            image-url="@Url.Content("https://demos.telerik.com/aspnet-core/shared/icons/16/star.png")">
                <content>
                    <div class="weather">
                        <h2>29<span>&ordm;C</span></h2>
                        <p>Sunny weather in New York.</p>
                    </div>
                    <span class="sunny">&nbsp;</span>
                </content>
            </tabstrip-item>
        </items>
    </kendo-tabstrip>
</div>
```

## 4. Handle a TabStrip Event

The TabStrip component provides convenient events for implementing your desired logic. In this tutorial, you will use the exposed `Select()` event to log a new entry in the browser's console.

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

<h4>TabStrip with cities</h4>
<div>
<script>
    function select(e) {
        console.log("Selected old value :: " + this.value());
    }
</script>

@(Html.Kendo().TabStrip()
    .Name("tabstrip")
    .TabPosition(TabStripTabPosition.Top)
    .Events(e=>e.Select("select"))
    .Items(tabstrip =>
    {
        tabstrip.Add().Text("Paris")
            .Selected(true)
            .ImageUrl(Url.Content("https://demos.telerik.com/aspnet-core/shared/icons/16/photo.png"))
            .Content(@<text>
            <div class="weather">
                <h2>17<span>ºC</span></h2>
                <p>Rainy weather in Paris.</p>
            </div>
            <span class="rainy"> </span>
            </text>);

        tabstrip.Add().Text("New York")
            .ImageUrl(Url.Content("https://demos.telerik.com/aspnet-core/shared/icons/16/star.png"))
            .Content(@<text>
            <div class="weather">
                <h2>29<span>ºC</span></h2>
                <p>Sunny weather in New York.</p>
            </div>
            <span class="sunny"> </span>
            </text>);
    })
)
</div>
```

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

<h4>TabStrip with cities</h4>
<div>
    <script>
    function select(e) {
        console.log("Selected old value :: " + this.value());
    }
</script>

    <kendo-tabstrip name="tabstrip" tab-position="top" on-select="select">
        <items>
            <tabstrip-item text="Paris" selected="true" 
            image-url="@Url.Content("https://demos.telerik.com/aspnet-core/shared/icons/16/photo.png")">
                <content>
                    <div class="weather">
                        <h2>17<span>&ordm;C</span></h2>
                        <p>Rainy weather in Paris.</p>
                    </div>
                    <span class="rainy">&nbsp;</span>
                </content>
            </tabstrip-item>
            <tabstrip-item text="New York" 
            image-url="@Url.Content("https://demos.telerik.com/aspnet-core/shared/icons/16/star.png")">
                <content>
                    <div class="weather">
                        <h2>29<span>&ordm;C</span></h2>
                        <p>Sunny weather in New York.</p>
                    </div>
                    <span class="sunny">&nbsp;</span>
                </content>
            </tabstrip-item>
        </items>
    </kendo-tabstrip>
</div>
```

## 5. (Optional) Reference Existing TabStrip Instances

You can reference the TabStrip instances that you have created and build on top of their existing configuration:

1. Use the `id` attribute of the component instance to establish a reference.

   ```JS script
   <script>
       var tabstripReference = $("#tabstrip").data("kendoTabStrip"); // tabstripReference is a reference to the existing TabStrip instance of the helper.
   </script>
   ```

2. Use the [TabStrip client-side API](https://docs.telerik.com/kendo-ui/api/ui/tabstrip#methods) to control the behavior of the widget. In this example, you will use the `select` method to select an item.

   ```JS script
   <script>
       var tabstripReference = $("#tabstrip").data("kendoTabStrip"); // tabstripReference is a reference to the existing TabStrip instance of the helper.
       tabstripReference.select(3); 
   </script>
   ```

## 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 TabStrip HtmlHelper](https://netcorerepl.telerik.com/Qdalvrlh218JkVt549)
* [Sample code with the TabStrip TagHelper](https://netcorerepl.telerik.com/QHubbrFr23Qwf7NT06)

## Next Steps

* [Binding the TabStrip Items](https://docs.telerik.com/aspnet-core/html-helpers/navigation/tabstrip/binding/items-binding)
* [Configuring the TabStrip Content Area](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/navigation/tabstrip/content)
* [Configuring the Animation Effects of the TabStrip](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/navigation/tabstrip/animation)

## See Also

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