Claude
Skills
Sign in
Back

syncfusion-blazor-tabs

Included with Lifetime
$97 forever

````skill

General

What this skill does

````skill
---
name: syncfusion-blazor-tabs
description: Implement Syncfusion Blazor Tab component for tabbed navigation interfaces. Use this skill whenever the user needs to create tab navigation, organize content into tabs, handle tab selection, manage tab items, configure tab orientation, customize tab appearance, implement responsive tab modes, or build any tabbed interface in Blazor applications.
metadata:
  author: "Syncfusion Inc"
  version: "1.0.0"
  category: "Navigation"
---

# Implementing Syncfusion Blazor Tabs Component

## When to Use This Skill

Use the Syncfusion Blazor Tabs component when you need to:
- Organize content into multiple sections with tab-based navigation
- Create tabbed interfaces for content organization and switching
- Handle programmatic and user-driven tab selection
- Dynamically add, remove, or manage tab items
- Implement vertical or horizontal tab layouts
- Build responsive tab interfaces that adapt to different screen sizes
- Create nested tab structures for hierarchical content organization
- Customize tab appearance, styling, and animations
- Implement multi-step wizards with conditional navigation
- Enable drag-and-drop for tab reordering
- Persist tab state across page refreshes

## Component Overview

The Syncfusion Blazor Tabs component (`SfTab`) provides a flexible, accessible, and feature-rich tabbed navigation interface with support for:
- Multiple tab items with customizable headers and content
- Dynamic tab management (add/remove items programmatically)
- Multiple header placements (Top, Bottom, Left, Right)
- Responsive overflow modes (Scrollable, Popup)
- Two-way binding with `SelectedItem` property
- Comprehensive event system for user interactions
- Content rendering modes (Dynamic, On-Demand, Initial)
- Rich templating with `ContentTemplate` and `HeaderTemplate`
- Animation support with multiple effects
- State persistence through browser cookies
- Full keyboard and screen reader accessibility
- Drag-and-drop support for tab reordering

### Key Components
- **SfTab**: Main container component managing all tabs
- **TabItems**: Collection container for tab items
- **TabItem**: Individual tab with header and content
- **TabHeader**: Header configuration for tab title, icons, and positioning
- **TabEvents**: Event handlers for tab interactions
- **TabAnimationSettings**: Animation configuration for tab transitions
- **ContentTemplate**: Template for rendering complex content
- **HeaderTemplate**: Template for custom header rendering

---

## Installation and Setup

### Prerequisites
- .NET 6.0 or higher
- Blazor WebAssembly or Blazor Server application

### NuGet Package Installation

```csharp
// Install via Package Manager Console
Install-Package Syncfusion.Blazor.Navigations
Install-Package Syncfusion.Blazor.Themes
```

Or via .NET CLI:
```bash
dotnet add package Syncfusion.Blazor.Navigations
dotnet add package Syncfusion.Blazor.Themes
```

### Register Syncfusion Blazor Service

In **Program.cs**:
```csharp
using Syncfusion.Blazor;

var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.Services.AddSyncfusionBlazor();
await builder.Build().RunAsync();
```

### Add Namespaces

In **_Imports.razor**:
```csharp
@using Syncfusion.Blazor
@using Syncfusion.Blazor.Navigations
```

### Add Theme and Script References

In **index.html** (in `<head>` section):
```html
<link href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" />
<script src="_content/Syncfusion.Blazor.Core/scripts/syncfusion-blazor.min.js" type="text/javascript"></script>
```

---

## Basic Implementation

### Minimal Blazor Tabs Component Setup

```razor
@using Syncfusion.Blazor.Navigations

<SfTab>
    <TabItems>
        <TabItem>
            <ChildContent>
                <TabHeader Text="Tab 1"></TabHeader>
            </ChildContent>
            <ContentTemplate>
                <div>Content for Tab 1</div>
            </ContentTemplate>
        </TabItem>
        <TabItem>
            <ChildContent>
                <TabHeader Text="Tab 2"></TabHeader>
            </ChildContent>
            <ContentTemplate>
                <div>Content for Tab 2</div>
            </ContentTemplate>
        </TabItem>
        <TabItem>
            <ChildContent>
                <TabHeader Text="Tab 3"></TabHeader>
            </ChildContent>
            <ContentTemplate>
                <div>Content for Tab 3</div>
            </ContentTemplate>
        </TabItem>
    </TabItems>
</SfTab>
```

---

## Core API Reference

### SfTab Component Properties

| Property | Type | Default | Description | Example |
|----------|------|---------|-------------|---------|
| `AllowDragAndDrop` | bool | false | Enables drag-and-drop reordering of tabs | `AllowDragAndDrop="true"` |
| `CssClass` | string | null | CSS class applied to the Tab container | `CssClass="e-fill"` |
| `DragArea` | string | null | Sets the area to move the draggable element; dragging is restricted outside this area | `DragArea="body"` |
| `EnablePersistence` | bool | false | Enables state persistence in browser cookies | `EnablePersistence="true"` |
| `Height` | string | null | Height of the Tab component | `Height="250px"` |
| `HeaderPlacement` | HeaderPosition | Top | Position of tab headers (Top, Bottom, Left, Right) | `HeaderPlacement="HeaderPosition.Left"` |
| `ID` | string | null | Unique identifier for the component (required for persistence) | `ID="myTabs"` |
| `LoadOn` | ContentLoad | Dynamic | Content rendering mode (Dynamic, Demand, Init) | `LoadOn="ContentLoad.Demand"` |
| `OverflowMode` | OverflowMode | Scrollable | Behavior for overflowed tabs (Scrollable, Popup) | `OverflowMode="OverflowMode.Popup"` |
| `ReorderActiveTab` | bool | true | Reorders active tab when clicking from popup | `ReorderActiveTab="false"` |
| `ScrollStep` | int | 0 | Number of pixels to scroll when clicking navigation arrows | `ScrollStep="150"` |
| `SelectedItem` | int | 0 | Index of currently selected tab (supports two-way binding) | `@bind-SelectedItem="tabIndex"` |
| `ShowCloseButton` | bool | false | Shows close button on tab headers | `ShowCloseButton="true"` |
| `SwipeMode` | TabSwipeMode | TabSwipeMode.Touch \| TabSwipeMode.Mouse | Enables swipe gestures for tab navigation | `SwipeMode="TabSwipeMode.Touch"` |
| `Width` | string | null | Width of the Tab component | `Width="500px"` |
| `Locale` | string | "en-US" | Sets the locale for localization support | `Locale="fr-FR"` |
| `ShouldReinitialize` | bool | false | Gets or sets a value that indicates whether to re-initialize the tab content on every TabItem initialization | `ShouldReinitialize="true"` |

#### Property Examples

**Setting HeaderPlacement to create vertical tabs:**
```razor
<SfTab HeaderPlacement="HeaderPosition.Left" Height="250px" Width="500px">
    <TabItems>
        <!-- Tab items -->
    </TabItems>
</SfTab>
```

**Enabling drag-and-drop for tab reordering:**
```razor
<SfTab AllowDragAndDrop="true">
    <TabItems>
        <!-- Tab items -->
    </TabItems>
</SfTab>
```

**Restricting drag area with DragArea property:**
```razor
<div id="dragContainer" style="border: 2px solid blue; padding: 10px;">
    <SfTab AllowDragAndDrop="true" DragArea="#dragContainer">
        <TabItems>
            <TabItem>
                <ChildContent>
                    <TabHeader Text="Tab 1"></TabHeader>
                </ChildContent>
                <ContentTemplate>Tab 1 content</ContentTemplate>
            </TabItem>
            <TabItem>
                <ChildContent>
                    <TabHeader Text="Tab 2"></TabHeader>
                </ChildContent>
                <ContentTemplate>Tab 2 content</ContentTemplate>
            </TabItem>
            <TabItem>
                <ChildContent>
                    <TabHeader Text="Tab 3"></TabHeader>
                </ChildContent>
                <ContentTemplate>Tab 3 content</ContentTemplate>
            </TabItem>
    

Related in General