Tabs

The Tabs component provides a simple way to switch between multiple sections of related content using a tabbed interface.

Usage

Default


const [activeTab, setActiveTab] = useState(0);
const tabs = [
  { label: "Code", icon: FaCode, content: <div>Code content goes here.</div> },
  { label: "Music", icon: FaMusic, content: <div>Music player or list here.</div> },
  { label: "Images", icon: FaImage, content: <div>Gallery or image preview here.</div> },
];

<Tabs
  tabs={tabs}
  defaultIndex={activeTab}
  onChange={setActiveTab}
  theme="primary"
  size="medium"
/>

Props

Data table
TypeDescription
aria-describedbystringAccessible description id for the tablist.
aria-labelstringAccessible name for the tablist.
aria-labelledbystringAccessible labelledby id for the tablist. Preferred over aria-label when provided.
aria-live"off" | "polite" | "assertive"Optional aria-live setting if tab changes should be announced by a related region.
classNamestringCustom class names to apply to the tabs container.
data-testidstringTest ID for testing purposes.
defaultIndexnumberUncontrolled initial index.
idBasestringOptional stable base used to create ids: `${idBase}-tab-${i}` and `${idBase}-panel-${i}`
onChange((index: number) => void)Callback when the active tab changes.
roundingRoundingTypeRounding of the tabs. "none" | "small" | "medium" | "large" | "full"
shadowShadowTypeShadow style of the tabs. "none" | "light" | "medium" | "strong" | "intense"
sizeSizeTypeSize of the tabs. "xs" | "small" | "medium" | "large" | "xl"
stateStateTypeState of the tabs. "success" | "error" | "warning" | "disabled" | ""
tabListIdstringOptional id for the tablist element itself.
tabsTab[]Array of tabs to display.
themeThemeTypeTheme for styling the tabs. "primary" | "secondary" | "tertiary" | "quaternary" | "clear"
valuenumberControlled active tab index.