Skip to main content
Version: 1.0.3

Tab

The Tabs component is a versatile navigation interface that allows users to switch between different views within the same context. Built with Framer Motion for smooth animations and powered by Class Variance Authority for flexible styling, it provides multiple variants and themes for different design needs.

Installation

ignix add component tabs

Usage

Import the component:

import { Tabs } from '@ignix-ui/tab';

Basic Usage

function BasicTabs() {
return (
<Tabs
options={["Tab 1", "Tab 2", "Tab 3"]}
selected={0}
value={(index) => console.log(`Selected tab: ${index}`)}
/>
);
}

Persisting the Selected Tab

The selected tab is always remembered across a page refresh - no extra prop needed. The selection is saved to localStorage under a key derived from options, and restored on mount (falling back to selected when nothing is stored yet).

function PersistentTabs() {
return <Tabs options={["Tab 1", "Tab 2", "Tab 3"]} selected={0} />;
}

If two Tabs instances share the same options but need to remember their selection independently, give each one an explicit storageKey:

<Tabs options={["Tab 1", "Tab 2", "Tab 3"]} storageKey="sidebar-tabs" />
<Tabs options={["Tab 1", "Tab 2", "Tab 3"]} storageKey="main-content-tabs" />

Props

PropTypeDefaultDescription
optionsstring[]requiredArray of tab labels to render
selectednumber0Index of the initially selected tab
value(index: number) => voidundefinedCallback fired with the index of the newly selected tab
storageKeystringderived from optionsOverrides the localStorage key used to persist the selected tab (always on, surviving a page refresh); set this when multiple Tabs instances share identical options but must remember their selection independently
variant'underline' | 'filled' | 'pill' | 'outline' | 'ghost' | 'shadow' | 'gradient' | 'glow' | 'block''underline'Visual style of the tab strip
theme'light' | 'dark' | 'glass' | 'glassDark' | 'glassLight' | 'glassGradient' | 'glassGradientDark'undefinedColor theme applied to the tab container
size'sm' | 'md' | 'lg''md'Font size of the tab labels
classNamestringundefinedAdditional Tailwind classes applied to the tab container