| name | syncfusion-javascript-tab |
| description | This skill enables creating and customizing Syncfusion TypeScript Tab components, including tab navigation, tab headers, styling, responsive layouts, dynamic content loading, animations, and multi-panel organization. |
| metadata | {"author":"Syncfusion Inc","version":"34.1.29","category":"Navigation Components"} |
Implementing Syncfusion TypeScript Tab Component
The Syncfusion TypeScript Tab is a powerful content container that displays multiple contents in a specific space, one at a time. It supports rendering from JSON items or HTML elements, with extensive customization, animation, accessibility, and responsive design capabilities.
When to Use This Skill
- Basic Tab Setup: Create simple tabbed interfaces with headers and content
- Tab Selection & Navigation: Handle programmatic and user-initiated tab selection
- Customization: Style headers, content, icons, and selected states
- Responsive Design: Implement adaptive tabs with scrollable or popup modes
- Dynamic Content: Load tab items dynamically or through data sources
- Advanced Features: Drag-and-drop reordering, nested tabs, collapsible tabs, wizards
- User Experience: Add animations, tooltips, keyboard navigation, accessibility
- State Management: Persist tab state across sessions
Key Features
- Rendering: Create tabs from JSON items collection or HTML elements
- Adaptive: Responsive rendering with scrollable tabs and popup menus
- Customization: Header icons, orientation, styling, and theming support
- Animation: Built-in animation effects for tab transitions with
animation property
- Accessibility: WCAG compliance with keyboard navigation and ARIA attributes
- Drag & Drop: Reorder tabs and transfer items between interfaces with
allowDragAndDrop
- Dynamic Loading: Control content loading with
loadOn property (Demand, Dynamic, Init)
- State Persistence: Restore selected tab state across user sessions using
enablePersistence
- Security: Built-in HTML sanitization with
enableHtmlSanitizer to prevent XSS attacks
- Swipe Gestures: Tab navigation via touch/mouse swipe with
swipeMode property
Complete Enumeration Reference
HeaderPosition - Tab Header Placement
Controls where tab headers are positioned relative to content.
| Value | Placement | Use Case |
|---|
'Top' | Headers above content (default) | Dashboard, forms, standard tabs |
'Bottom' | Headers below content | Document viewers, bottom navigation |
'Left' | Headers on left side | Admin panels, sidebar navigation |
'Right' | Headers on right side | Specialized layouts |
new Tab({ headerPlacement: 'Top', items: [...] });
new Tab({ headerPlacement: 'Left', items: [...] });
new Tab({ headerPlacement: 'Bottom', items: [...] });
new Tab({ headerPlacement: 'Right', items: [...] });
HeightStyles - Content Height Adjust Modes
Controls how tab content height is calculated.
| Value | Behavior | Usage |
|---|
'None' | Use explicit height property | Fixed containers |
'Auto' | All tabs match tallest content | Equalizing heights |
'Content' | Each tab matches its own content (default) | Variable-height content |
'Fill' | Content fills parent container | Responsive fills |
new Tab({ height: '400px', heightAdjustMode: 'None', items: [...] });
new Tab({ heightAdjustMode: 'Auto', items: [...] });
new Tab({ heightAdjustMode: 'Content', items: [...] });
new Tab({ height: '100%', heightAdjustMode: 'Fill', items: [...] });
ContentLoad - Content Rendering Modes
Controls when tab content is loaded into the DOM.
| Value | Loading | DOM | When Used |
|---|
'Demand' (default) | On first selection | Persists | Many tabs, static content |
'Dynamic' | On each selection | Only selected | Dynamic/live data |
'Init' | All upfront | Always in DOM | Few tabs, small content |
new Tab({ loadOn: 'Demand', items: [...] });
new Tab({ loadOn: 'Dynamic', items: [...] });
new Tab({ loadOn: 'Init', items: [...] });
TabSwipeMode - Swipe Gesture Control
Controls which input methods trigger tab swiping.
| Value | Touch | Mouse | Desktop | Mobile |
|---|
'Both' (default) | ✅ | ✅ | All devices | All devices |
'Touch' | ✅ | ❌ | Desktop only | Mobile users |
'Mouse' | ❌ | ✅ | Desktop users | Mouse input only |
'None' | ❌ | ❌ | Swiping disabled | Swiping disabled |
new Tab({ swipeMode: 'Both', items: [...] });
new Tab({ swipeMode: 'Touch', items: [...] });
new Tab({ swipeMode: 'Mouse', items: [...] });
new Tab({ swipeMode: 'None', items: [...] });
Core Documentation (Start Here)
-
Getting Started ⭐ START HERE
- Installation and setup
- First Tab component
- HTML structure and imports
-
Tab Structure and Content
- Tab item structure
- Headers and content
- Tab selection
API Reference & Properties
-
Complete API Properties Reference 📚 COMPREHENSIVE
- All 24+ properties documented
- Usage examples for each property
- Property combinations and recommendations
- Core, rendering, interaction, animation properties
-
Event Handling Reference 📚 COMPREHENSIVE
- All 11 events documented
- Event arguments (SelectEventArgs, SelectingEventArgs, DragEventArgs, etc.)
- Event lifecycle and timing
- Practical event patterns
-
Complete Methods Reference 📚 COMPREHENSIVE
- All 18 methods documented with signatures and parameters
- Tab management methods (addTab, removeTab, select)
- Visibility and state control (hideTab, enableTab, disable)
- Event management (addEventListener, removeEventListener)
- Component lifecycle (destroy, refresh, refreshActiveTab)
- Utility methods (getItemIndex, getRootElement, appendTo, dataBind)
- Practical code examples for each method
- Method interaction patterns and best practices
Customization & Styling
- Customization and Styling
- CSS structure
- Header and content styling
showCloseButton property
- Built-in themes
- Custom styling examples
Content & Data
- Data Binding and Dynamic Content
- Loading methods (JSON, AJAX, DataManager)
loadOn property (Demand, Dynamic, Init)
addTab() and removeTab() methods
- POST requests and API integration
- Content rendering modes
Layout & Responsiveness
-
Content Orientation and Header Placement
headerPlacement (Top, Bottom, Left, Right)
- Horizontal vs vertical layouts
- Responsive design patterns
- Sidebar navigation implementation
-
Responsive and Adaptive Modes
- Scrollable mode
- Popup/dropdown mode
- Multi-row mode
overflowMode property
Advanced & Features
-
Advanced Features
- Drag and drop (
allowDragAndDrop, dragArea)
reorderActiveTab property
- Nested and collapsible tabs
- Tab-based wizards
- Icon and tooltip integration
-
Animation and Transitions
animation property (TabAnimationSettingsModel)
- Effects: SlideLeftIn, SlideRightIn, FadeIn, ZoomIn, etc.
swipeMode property (Both, Touch, Mouse, None)
- Custom animation timing
-
State Persistence
enablePersistence property
- localStorage-based persistence
- Multi-tab forms and dashboards
- Advanced persistence patterns
Accessibility & Internationalization
- Accessibility and Localization
- WCAG compliance and ARIA
- Keyboard navigation
enableRtl property (RTL support)
locale property (i18n)
Security
- Security and HTML Sanitization 🔒 IMPORTANT
enableHtmlSanitizer property
- XSS prevention
- User content protection
- Security best practices
Troubleshooting
- Edge Cases and Troubleshooting
- Height and scroll management
- Browser compatibility
Quick Start
Basic Tab with JSON Items
import { Tab } from '@syncfusion/ej2-navigations';
let tabObj: Tab = new Tab({
items: [
{
header: { 'text': 'Twitter' },
content: 'Twitter is an online social networking service...'
},
{
header: { 'text': 'Facebook' },
content: 'Facebook is an online social networking service...'
},
{
header: { 'text': 'WhatsApp' },
content: 'WhatsApp Messenger is a proprietary cross-platform...'
}
]
});
tabObj.appendTo('#element');
HTML Structure
<!DOCTYPE html>
<html lang="en">
<head>
<title>Tab Example</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<div id="element"></div>
</body>
</html>
CSS Setup
@import '../../node_modules/@syncfusion/ej2-base/styles/fluent2.css';
@import '../../node_modules/@syncfusion/ej2-buttons/styles/fluent2.css';
@import '../../node_modules/@syncfusion/ej2-popups/styles/fluent2.css';
@import '../../node_modules/@syncfusion/ej2-navigations/styles/fluent2.css';
Feature-Specific Usage Scenarios
Tab Content Height Customization
Use the heightAdjustMode property to control how tab content height is adjusted:
let tabObj: Tab = new Tab({
heightAdjustMode: 'Auto',
height: '400px',
items: [
{ header: { 'text': 'Tab 1' }, content: 'Short content' },
{ header: { 'text': 'Tab 2' }, content: 'Much longer content with more text...' },
{ header: { 'text': 'Tab 3' }, content: 'Another tab with varying content length' }
]
});
tabObj.appendTo('#element');
Height Modes:
- None: Content height matches Tab container height (requires explicit height)
- Auto: All tabs adjust to match the tallest content
- Content: Each tab adjusts to its own content height (default)
- Fill: Tab content fills the parent element completely
Show Close Button on Tabs
Enable users to close individual tabs by clicking a close button:
let tabObj: Tab = new Tab({
showCloseButton: true,
items: [
{ header: { 'text': 'Home' }, content: 'Home content...' },
{ header: { 'text': 'Editor' }, content: 'Editor content...' },
{ header: { 'text': 'Settings' }, content: 'Settings content...' }
]
});
tabObj.appendTo('#element');
tabObj.element.addEventListener('close', (e: any) => {
console.log(`Closed tab at index: ${e.index}`);
});
Reorder Active Tab in Popup Mode
Control how the active tab behaves when tabs overflow into a popup menu:
let tabObj: Tab = new Tab({
overflowMode: 'Popup',
reorderActiveTab: false,
heightAdjustMode: 'Auto',
items: [
{ header: { 'text': 'India' }, content: 'India content...' },
{ header: { 'text': 'Canada' }, content: 'Canada content...' },
{ header: { 'text': 'Australia' }, content: 'Australia content...' },
]
});
tabObj.appendTo('#element');
When reorderActiveTab is true (default), clicking a tab in the popup moves it to the main view. When false, the tab remains highlighted in the popup without being reordered to the main view.
Load Tab Items Dynamically
Add tabs programmatically in response to user actions:
let tabObj: Tab = new Tab({
items: [
{ header: { 'text': 'Home' }, content: 'Home content' }
]
});
tabObj.appendTo('#element');
document.getElementById('addTabBtn')?.addEventListener('click', () => {
let newTabCount = tabObj.items.length;
let newTab = {
header: { 'text': `Tab ${newTabCount}` },
content: `Content for tab ${newTabCount}`
};
tabObj.addTab([newTab]);
});
document.getElementById('removeTabBtn')?.addEventListener('click', () => {
if (tabObj.items.length > 1) {
tabObj.removeTab(tabObj.items.length - 1);
}
});
State Persistence Across Page Refreshes
Automatically save and restore the selected tab:
let tabObj: Tab = new Tab({
enablePersistence: true,
items: [
{ header: { 'text': 'Dashboard' }, content: 'Dashboard...' },
{ header: { 'text': 'Analytics' }, content: 'Analytics...' },
{ header: { 'text': 'Settings' }, content: 'Settings...' }
]
});
tabObj.appendTo('#element');
Customize Selected Tab Appearance
Use CSS classes to override default styling for selected tabs:
let tabObj: Tab = new Tab({
cssClass: 'e-tab-custom-style',
items: [...]
});
tabObj.appendTo('#element');
Then define custom CSS:
.e-tab.e-tab-custom-style .e-tab-header .e-toolbar-item.e-active {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border-bottom: 3px solid #667eea;
}
.e-tab.e-tab-custom-style .e-tab-header .e-toolbar-item.e-active .e-tab-text {
font-weight: 600;
color: white;
}
Load Content Through POST Requests
Fetch tab content from a server:
import { Tab } from '@syncfusion/ej2-navigations';
import { Ajax } from '@syncfusion/ej2-base';
let ajax: Ajax = new Ajax('./api/tab-content', 'GET', true);
ajax.onSuccess = (data: string): void => {
let tabObj: Tab = new Tab({
items: [
{ header: { 'text': 'Home' }, content: 'Home content' },
{ header: { 'text': 'Remote Content' }, content: data }
]
});
tabObj.appendTo('#element');
};
ajax.send();
async function loadTabContent() {
try {
let response = await fetch('api/tab-data', { method: 'POST' });
let data = await response.();
tabObj = ({
: data.
});
tabObj.();
} (error) {
.(, error);
}
}
();
Drag and Drop Between Tabs or External Sources
Enable users to move tab items within the same tab or to external components:
let tabObj: Tab = new Tab({
allowDragAndDrop: true,
dragArea: '#dragContainer',
items: [...],
dragged: (args) => {
console.log(`Item moved from ${args.draggedIndex} to ${args.droppedIndex}`);
}
});
tabObj.appendTo('#element');
let sourceTab: Tab = new Tab({
allowDragAndDrop: true,
dragArea: '#container',
items: [{ header: { 'text': 'Source 1' }, content: 'Can be moved' }]
});
sourceTab.appendTo('#sourceTab');
let destTab: Tab = new Tab({
allowDragAndDrop: true,
dragArea: '#container',
items: [{ header: { 'text': }, : }]
});
destTab.();
Content Rendering Modes
Control how and when tab content is loaded:
let tabObj: Tab = new Tab({
items: [
{ header: { 'text': 'Tab 1' }, content: 'Content loaded on first select' }
]
});
tabObj.appendTo('#element');
let dynamicTab: Tab = new Tab({
loadOn: 'Dynamic',
items: []
});
dynamicTab.appendTo('#element');
let initialTab: Tab = new Tab({
loadOn: 'Init',
items: []
});
initialTab.appendTo('#element');
Common Patterns
Pattern 1: Programmatic Tab Selection
tabObj.select(1);
let activeIndex = tabObj.selectedItem;
tabObj.selecting = (args) => {
if (args.isInteracted) {
console.log('User clicked tab');
} else {
console.log('Tab selected programmatically');
}
};
Pattern 2: Dynamic Tab Addition
tabObj.addTab([
{
header: { 'text': 'New Tab' },
content: 'New content here'
}
], 2);
Pattern 3: Responsive Tabs with Scrolling
let tabObj: Tab = new Tab({
items: [...],
heightAdjustMode: 'Auto',
overflowMode: 'Scrollable'
});
Pattern 4: Tab with Icons
let tabObj: Tab = new Tab({
items: [
{
header: {
'text': 'Settings',
'iconCss': 'e-icon-settings'
},
content: 'Settings content...'
}
]
});
Key Props and Configuration
| Property | Type | Purpose | Common Values |
|---|
items | Array | Tab items collection | Array of item objects |
selectedItem | number | Active tab index | 0, 1, 2, ... |
heightAdjustMode | string | Auto-adjust height | 'Auto', 'Content', 'Scroll' |
overflowMode | string | Handle overflow tabs | 'Scrollable', 'Popup', 'MultiRow' |
animation | object | Animation settings | { previous, next } |
headerPlacement | string | Header placement | 'Top', 'Bottom', 'Left', 'Right' |
enableRtl | boolean | RTL support | true, false |
allowDragAndDrop | boolean | Enable drag-drop | true, false |
enablePersistence | boolean | State persistence | true, false |
Common Use Cases
- Multi-Panel Forms: Organize form fields across multiple tabs with validation
- Documentation Sites: Create tabbed code examples (TypeScript, JavaScript, HTML)
- Dashboard Layouts: Organize dashboard widgets in tab sections
- Step-by-Step Wizards: Create sequential workflows using tabs
- Content Organization: Categorize and display large datasets
- Feature Toggles: Show/hide related features in tab panels
- Admin Interfaces: Organize settings and configuration options
- Mobile Navigation: Responsive tab-based navigation for small screens
Next Steps:
- Read the appropriate reference file based on your use case
- Check the quick start example for basic setup
- Review common patterns for your specific scenario
- Refer to edge cases guide for troubleshooting