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-tabsThis 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} />;Links
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
| Prop | Type | Default | Description |
|---|---|---|---|
items | ExpandableTabsItem[] | — | The tabs to render. |
value | string | — | Controlled active value. |
defaultValue | string | first item | Initial active value when uncontrolled. |
onValueChange | (value: string) => void | — | Called when the active tab changes. |
label | string | "Choose an option" | Accessible label for the tab group. |
className | string | — | Extra classes for the tab container. |
ExpandableTabsItem
| Field | Type | Description |
|---|---|---|
value | string | Unique identifier for the tab. |
label | string | Text shown when active and in the tooltip. |
icon | ReactNode | Icon rendered in both collapsed and active states. |
href | string? | When set, the tab renders as a link instead of a button. |