Continuous Tabs Free React component
A tab bar where the active highlight glides and stretches from one tab to the next instead of jumping, using a shared layout animation.
Original component by Watermelon UI · MIT licence
Get the code
npx shadcn@latest add https://registry.watermelon.sh/r/continuous-tabs.jsonInstalls from the Watermelon UI registry through the shadcn CLI. Needs Tailwind CSS and the motion package, which the command adds for you.
import { ContinuousTabs } from '../continuous-tabs'
function ContinuousTabsDemo() {
return (
<div className="flex items-center justify-center">
<ContinuousTabs
tabs={[
{ id: "home", label: "Home" },
{ id: "design", label: "Design" },
{ id: "code", label: "Code" },
{ id: "deploy", label: "Deploy" },
]}
/>
</div>
)
}
export default ContinuousTabsDemo// continuous-tabs, from Watermelon UI: https://ui.watermelon.sh/animated-components/continuous-tabs
// MIT License. Copyright (c) 2025-present Watermelon Contributors.
"use client";
import { useState, useEffect, type FC } from "react";
import { motion, LayoutGroup } from "framer-motion";
/* ---------- Types ---------- */
interface TabItem {
id: string;
label: string;
}
interface ContinuousTabsProps {
tabs?: TabItem[];
defaultActiveId?: string;
onChange?: (id: string) => void;
}
/* ---------- Defaults ---------- */
const DEFAULT_TABS: TabItem[] = [
{ id: "home", label: "Home" },
{ id: "interactions", label: "Interactions" },
{ id: "resources", label: "Resources" },
{ id: "docs", label: "Docs" },
];
export const ContinuousTabs: FC<ContinuousTabsProps> = ({
tabs = DEFAULT_TABS,
defaultActiveId = "home",
onChange,
}) => {
const [active, setActive] = useState<string>(defaultActiveId);
const [isMounted, setIsMounted] = useState<boolean>(false);
useEffect(() => {
setIsMounted(true);
}, []);
const handleChange = (id: string) => {
setActive(id);
onChange?.(id);
};
if (!isMounted) return null;
return (
<LayoutGroup>
<nav
className="
relative flex items-center gap-0.5 sm:gap-1 p-1 sm:p-1.5
rounded-full
border border-[#E5E5E9] dark:border-zinc-800
bg-linear-to-b from-[#ffffff] to-[#e9e9f2]
dark:from-zinc-900 dark:to-zinc-950
shadow-[inset_0_-2px_4px_rgba(0,0,0,0.08),
inset_0_1px_0_rgba(255,255,255,0.9),
0_4px_12px_rgba(0,0,0,0.03)]
dark:shadow-[inset_0_-2px_4px_rgba(0,0,0,0.5),
inset_0_1px_0_rgba(255,255,255,0.05),
0_10px_20px_rgba(0,0,0,0.4)]
transition-all duration-300
"
>
{tabs.map((tab) => {
const isActive = active === tab.id;
return (
<button
key={tab.id}
onClick={() => handleChange(tab.id)}
className="relative px-4 py-2 sm:px-6 sm:py-3 rounded-full outline-none"
>
{/* Active pill */}
{isActive && (
<motion.div
layoutId="active-pill"
transition={{
type: "spring",
stiffness: 380,
damping: 30,
mass: 0.9,
}}
className="
absolute inset-0 rounded-full
bg-[#252528] dark:bg-zinc-100
shadow-xs
"
/>
)}
{/* Text */}
<motion.span
layout="position"
className={`relative z-10 text-sm sm:text-base font-semibold transition-colors duration-200
${isActive
? "text-[#EDEDEC] dark:text-zinc-950"
: "text-[#343437] dark:text-zinc-500 hover:text-[#62625D] dark:hover:text-zinc-300"
}
`}
>
{tab.label}
</motion.span>
</button>
);
})}
</nav>
</LayoutGroup>
);
};Paste this into Claude, ChatGPT, Cursor, Lovable or v0 to build it from scratch.
Build a React component called "Continuous Tabs" with Tailwind CSS and Motion (motion/react). A tab bar where the active highlight glides and stretches from one tab to the next instead of jumping, using a shared layout animation. Use spring transitions, keep it accessible with keyboard focus and aria labels, respect prefers-reduced-motion, and make it work on touch screens. Export it as a single .tsx file with sensible default props so it renders a complete demo on its own.How the continuous tabs works
A tab bar where the active highlight glides and stretches from one tab to the next instead of jumping, using a shared layout animation. The component is a single TypeScript file built with React, Tailwind CSS and Motion, so the animation runs on springs and shared layouts instead of hand-written keyframes.
It comes from Watermelon UI, an open-source component library released under the MIT licence. Install it with the shadcn command above, or copy the source from the code tab into your project.
Frequently asked questions
Want motion like this on your website?
We design and build custom websites with motion, 3D and SEO built in. Websites from $500.