dominik-ui

Expandable Tabs

Animated icon tabs with a sliding active pill and an expanding label, built on the shadcn tooltip.

Preview

import { ExpandableTabs } from "@/components/ui/expandable-tabs";

export function Example() {
  return (
    <ExpandableTabs
      label="Choose your client"
      items={[
        { value: "react", label: "React", icon: <ReactIcon /> },
        { value: "next", label: "Next.js", icon: <NextIcon /> },
        { value: "bun", label: "Bun", icon: <BunIcon /> },
        { value: "tailwind", label: "Tailwind", icon: <TailwindIcon /> },
      ]}
    />
  );
}

Installation

$ pnpm dlx shadcn@latest add @dominik-ui/expandable-tabs

This pulls in the tooltip component automatically. The sliding pill and expanding label are plain CSS — no animation library needed.

Usage

import { ExpandableTabs } from "@/components/ui/expandable-tabs";

const items = [
  { value: "react", label: "React", icon: <ReactIcon /> },
  { value: "next", label: "Next.js", icon: <NextIcon /> },
];

export function Example() {
  return <ExpandableTabs items={items} label="Choose your client" />;
}

Only the active tab reveals its label; the rest collapse to their icon. Hovering a collapsed tab shows its label in a tooltip.

Controlled vs uncontrolled

By default the component manages its own selection (defaultValue sets the initial tab). Pass value and onValueChange to control it yourself:

const [tab, setTab] = useState("react");

<ExpandableTabs items={items} onValueChange={setTab} value={tab} />;

Give an item an href and it renders as an anchor with aria-current instead of a button — handy for navigation rails:

const items = [
  { value: "home", label: "Home", icon: <HomeIcon />, href: "/" },
  { value: "docs", label: "Docs", icon: <DocsIcon />, href: "/docs" },
];

Props

PropTypeDefaultDescription
itemsExpandableTabsItem[]—The tabs to render.
valuestring—Controlled active value.
defaultValuestringfirst itemInitial active value when uncontrolled.
onValueChange(value: string) => void—Called when the active tab changes.
labelstring"Choose an option"Accessible label for the tab group.
classNamestring—Extra classes for the tab container.

ExpandableTabsItem

FieldTypeDescription
valuestringUnique identifier for the tab.
labelstringText shown when active and in the tooltip.
iconReactNodeIcon rendered in both collapsed and active states.
hrefstring?When set, the tab renders as a link instead of a button.

On this page