|
1 | 1 | --- |
2 | 2 | layout: post |
3 | | -title: Add/Remove Tab items in Blazor Tabs Component | Syncfusion |
| 3 | +title: Add/Remove Tab Items in Blazor Tabs Component | Syncfusion |
4 | 4 | description: Checkout and learn here all about how to add or remove tab items in Syncfusion Blazor Tabs component and more. |
5 | 5 | platform: Blazor |
6 | 6 | control: Tabs |
7 | 7 | documentation: ug |
8 | 8 | --- |
9 | 9 |
|
10 | | -# Add/Remove Tab items in Blazor Tabs Component |
| 10 | +# Add/Remove Tab Items in Blazor Tabs Component |
11 | 11 |
|
12 | | -Tabs provides a support to add or remove the specified tab item using following ways. |
| 12 | +The Tabs component supports adding or removing specified tab items dynamically using the following methods: |
13 | 13 |
|
14 | 14 | * Using conditional rendering. |
15 | 15 | * Using public methods. |
16 | 16 |
|
17 | | -## Using conditional rendering |
| 17 | +## Using Conditional Rendering |
18 | 18 |
|
19 | | -Tab items can be added or removed dynamically by iteration of tab items using conditional **foreach** loop. |
| 19 | +Tab items can be added or removed dynamically by conditionally rendering them within a `foreach` loop. |
20 | 20 |
|
21 | | -In the following demo, initially there are three tabs as the **TabItems** has three items. On `Add Item` button click, new item is added to the **TabItems** results in adding fourth tab to the Tabs component. On clicking the `Remove Item`, the first item of **TabItems** has been removed which results in removing first tab of our Tabs component. |
| 21 | +In the following demo, initially, three tabs are present based on the `TabItems` collection. When the `Add Item` button is clicked, a new item is added to `TabItems`, resulting in a new (fourth) tab being displayed. Clicking the `Remove Item` button removes the first item from `TabItems`, which, in turn, removes the first tab from the Tabs component. |
22 | 22 |
|
23 | 23 | ```cshtml |
24 | 24 | @using Syncfusion.Blazor.Navigations |
@@ -88,11 +88,13 @@ In the following demo, initially there are three tabs as the **TabItems** has th |
88 | 88 | } |
89 | 89 | ``` |
90 | 90 |
|
| 91 | +{% previewsample "https://blazorplayground.syncfusion.com/embed/hNVIMXXuJouUThMs?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %} |
| 92 | + |
91 | 93 |  |
92 | 94 |
|
93 | | -## Using public methods |
| 95 | +## Using Public Methods |
94 | 96 |
|
95 | | -Tabs can be added dynamically by passing list of items and index value to the `AddTab` method. The tab items can be removed by passing the specified item through `RemoveTab` method. Tab items can also be removed by clicking the close icon which appears on the tab header on setting true to `ShowCloseButton` property. |
| 97 | +Tabs can be added dynamically by passing a list of `TabItem` objects and an index value to the `AddTab` method. Tab items can be removed by passing the item's index to the `RemoveTab` method. Tab items can also be removed by clicking the close icon, which appears on the tab header when the `ShowCloseButton` property is set to `true`. |
96 | 98 |
|
97 | 99 | In the following demo, a tab item can be added as first tab and removed as the last tab item by clicking the **Add Tab** and **Remove Last Tab** buttons respectively. |
98 | 100 |
|
@@ -148,5 +150,6 @@ In the following demo, a tab item can be added as first tab and removed as the l |
148 | 150 | } |
149 | 151 | </style> |
150 | 152 | ``` |
| 153 | +{% previewsample "https://blazorplayground.syncfusion.com/embed/hXrSCjjupRNsuVnI?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %} |
151 | 154 |
|
152 | 155 |  |
0 commit comments