LibraryComponents

ExpandableTabs

Animated icon tabs that expand to show labels on selection.

ExpandableTabs

Domain: navigation
Package path: packages/ui/src/navigation/expandable-tabs.tsx
Import: @ziteox/ui or @ziteox/ui/navigation

Horizontal tab strip. Icons only by default; the selected tab expands with a spring animation to reveal its label. Click outside to deselect.

Preview

ExpandableTabs

Usage

Pass icons from your app (e.g. lucide-react). @ziteox/ui does not bundle icon libraries.

import { ExpandableTabs } from "@ziteox/ui";
import { Bell, Home, Settings } from "lucide-react";

const tabs = [
  { title: "Dashboard", icon: Home },
  { title: "Notifications", icon: Bell },
  { type: "separator" },
  { title: "Settings", icon: Settings },
];

export function NavTabs() {
  return (
    <ExpandableTabs
      tabs={tabs}
      onChange={(index) => console.log("selected", index)}
    />
  );
}

Install the motion peer in your app. Icons come from your app (for example lucide-react); they are not a package peer.

pnpm add motion

Props

PropTypeRequiredDescription
tabsExpandableTabItem[]YesTab definitions or { type: "separator" }
classNamestringNoAppended to root container
activeClassNamestringNoExtra class on the selected tab button
onChange(index: number | null) => voidNoSelection changes; null when cleared

Tab items

{ title: "Dashboard", icon: Home }
{ type: "separator" }

icon must be a React component accepting optional size?: number.

Animation

  • motion/react for button gap/padding and label width
  • Spring transition (bounce: 0, duration: 0.6)
  • Click outside clears selection (useOnClickOutside in package)

Styling

Scoped CSS with ziteox-expandable-tabs-* classes. Theme-aware via .dark / [data-theme="dark"].

No Tailwind inside the package. Use className and activeClassName only if your app needs extra layout or overrides on top of the built-in styles.