Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Animated Tabs

Free

Tabs with an indicator that glides between triggers. Pill and underline variants.

Installation

pnpm dlx shadcn@latest add @viewport/animated-tabs

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above.

animated-tabs-demo.tsx
"use client";

import { useState } from "react";
import { AnimatedTabs } from "@/components/viewport/animated-tabs";

const tabs = [
  { value: "overview", label: "Overview", content: "A summary of traffic, revenue and active users for the last 30 days." },
  { value: "analytics", label: "Analytics", content: "Break results down by source, campaign, device and country." },
  { value: "reports", label: "Reports", content: "Schedule a PDF or CSV export to your inbox every Monday." },
  { value: "settings", label: "Settings", content: "Manage tracking domains, team access and data retention." },
];

export default function AnimatedTabsDemo() {
  const [pill, setPill] = useState("overview");
  const [line, setLine] = useState("overview");
  return (
    <div className="flex w-full max-w-md flex-col gap-10">
      <AnimatedTabs
        label="Dashboard sections"
        value={pill}
        onValueChange={setPill}
        tabs={tabs.map((t) => ({ ...t, content: <p className="text-sm text-muted-foreground">{t.content}</p> }))}
      />
      <AnimatedTabs label="Dashboard sections, underline" variant="underline" value={line} onValueChange={setLine} tabs={tabs.map(({ value, label }) => ({ value, label }))} />
    </div>
  );
}

Props

PropTypeDefault
tabs*Tab[]—
value*string—
onValueChange*(value: string) => void—
labelstring

Accessible name for the tab list.

"Tabs"
variant"pill" | "underline"

"pill" slides a filled segment, "underline" slides a line.

"pill"
classNamestring—

Accessibility

  • Built on Radix Tabs: arrow keys, Home and End.
  • Panels are labelled by their tab.
  • The list scrolls horizontally on narrow screens.