erictsai83

Expandable Segmented Tabs

Navigation

About

A Motion-powered segmented tab list for switching modes or views, with an active tab that expands from icon-only into a label.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Expandable Segmented Tabs to your project and fits it to your theme.

Code

How Expandable Segmented Tabs is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import { useMemo, useState } from "react";
import { BookOpen, MessageSquareText, Rows3 } from "lucide-react";

import {
  ExpandableSegmentedTabs,
  type ExpandableSegmentedTabsItem,
} from "@/components/ui/ericts-expandable-segmented-tabs";

const items: ExpandableSegmentedTabsItem[] = [
  {
    value: "discuss",
    label: "Discuss",
    icon: <MessageSquareText className="size-4" />,
  },
  {
    value: "library",
    label: "Library",
    icon: <BookOpen className="size-4" />,
  },
  {
    value: "queue",
    label: "Queue",
    icon: <Rows3 className="size-4" />,
  },
];

const descriptions: Record<string, string> = {
  discuss: "Live questions and follow-up threads.",
  library: "Saved references and source material.",
  queue: "Open review items waiting for action.",
};

export default function Preview() {
  const [value, setValue] = useState(items[0].value);
  const activeItem = useMemo(
    () => items.find((item) => item.value === value) ?? items[0],
    [value],
  );

  return (
    <div className="flex w-full max-w-72 flex-col items-center gap-4">
      <ExpandableSegmentedTabs
        items={items}
        value={value}
        onValueChange={setValue}
        aria-label="Workspace mode"
      />
      <div className="w-full rounded-lg border bg-background px-4 py-3 text-center">
        <p className="text-sm font-medium">{activeItem.label}</p>
        <p className="mt-1 text-xs text-muted-foreground">
          {descriptions[activeItem.value]}
        </p>
      </div>
    </div>
  );
}

Dependencies

More by erictsai83

View all
  • Adaptive Drawer

    Adaptive Drawer

  • Status Button

    Status Button

  • Floating Shortcut Button

    Floating Shortcut Button

  • Filter Tags

    Filter Tags

  • Feedback Popover

    Feedback Popover

  • Expandable Toolbar

    Expandable Toolbar

  • Expandable Toggle Button

    Expandable Toggle Button

  • Arc Menu

    Arc Menu

More in Navigation

View all
  • Footer with Big Wordmark

    Footer with Big Wordmark

    163
  • Liquid Glass Expandable Sidebar

    Liquid Glass Expandable Sidebar

    437
  • Meniscus — Liquid Bottom Navigation Bar

    Meniscus — Liquid Bottom Navigation Bar

    31
  • Sidebar

    Sidebar

    444
  • Tabs

    Tabs

    38
  • Pagination

    Pagination

    119
  • Sidebar

    Sidebar

    367
  • Stacked Circular Footer

    Stacked Circular Footer

    469