Skip to main content
Version: 1.0.3

Tab Navigation

Tab Navigation is a section content template that provides a horizontal tab list with a clear active indicator, content switching, optional icons (with positions: left, right, top), optional badges (with or without counter, and shapes: pill, circle, square), and custom active/inactive colors. It supports full keyboard navigation (Arrow Left/Right, Enter/Space, Home/End) and is built for minimal re-renders using callbacks and stable refs.

Features:

  • Horizontal tab list with underline or pill active indicator
  • Tab content switching
  • Optional icons with positions: left, right, top
  • Optional badges: counter or label, shapes pill / circle / square
  • Custom active and inactive colors via class names
  • Keyboard support: Arrow keys, Enter, Space, Home, End

Overview

This is the overview content. Tabs switch content when you click or use the keyboard. Use Arrow Left/Right to move between tabs and Enter or Space to activate.


Installation

ignix add component tab-navigation

Usage

Import the component and define tabs with id, label, content, and optional icon, iconPosition, and badge:

import TabNavigation from '@ignix-ui/tabnavigation';
import { FileText, Settings } from 'lucide-react';

const tabs = [
{
id: 'overview',
label: 'Overview',
icon: FileText,
iconPosition: 'left',
badge: { count: 3, shape: 'pill' },
content: <div>Overview content...</div>,
},
{
id: 'settings',
label: 'Settings',
icon: Settings,
iconPosition: 'right',
content: <div>Settings content...</div>,
},
];

function MyTabs() {
return (
<TabNavigation
tabs={tabs}
indicatorVariant="underline"
defaultActiveId="overview"
onChange={(activeId) => console.log(activeId)}
/>
);
}

Controlled mode

const [activeId, setActiveId] = useState('overview');

<TabNavigation
tabs={tabs}
activeId={activeId}
onChange={setActiveId}
indicatorVariant="pill"
/>

Custom colors

<TabNavigation
tabs={tabs}
activeTabClassName="text-emerald-600"
inactiveTabClassName="text-slate-500 hover:text-slate-700"
activeIndicatorClassName="bg-emerald-600"
/>

Props

TabNavigation

PropTypeDefaultDescription
tabsTabItem[]requiredArray of tab definitions (id, label, content, optional icon, iconPosition, badge).
defaultActiveIdstringfirst tab idInitial active tab id (uncontrolled).
activeIdstring-Controlled active tab id.
onChange(activeId: string) => void-Callback when the active tab changes.
classNamestring-Root container class.
tabListClassNamestring-Horizontal tab list class.
panelClassNamestring-Content panel class.
indicatorVariant'underline' | 'pill''underline'Style of the active indicator.
activeTabClassNamestring-Class for active tab (e.g. text/background color).
inactiveTabClassNamestring-Class for inactive tabs.
activeIndicatorClassNamestring-Class for the underline indicator bar.

TabItem

PropTypeDescription
idstringrequired – Unique tab id.
labelstringrequired – Tab label.
contentReact.ReactNoderequired – Panel content when active.
iconLucideIconOptional icon component.
iconPosition'left' | 'right' | 'top'Icon position (default 'left').
badge{ label?: string; count?: number; showZero?: boolean; shape?: 'pill' | 'circle' | 'square' }Optional badge (counter or label, shape).

Keyboard: Arrow Left/Right (or Up/Down) move focus and active tab; Enter or Space activate; Home/End go to first/last tab.