Free · MIT licence · Tailwind + Motion

Discrete Tabs Free React component

Compact icon tabs: the active one widens to reveal its label while the others shrink back to icons, with a springy width animation.

Original component by Watermelon UI · MIT licence

  • React
  • CSS
  • Tabs
  • Icons
  • Navigation
Discrete Tabs

Get the code

Install in one linenpx shadcn@latest add https://registry.watermelon.sh/r/discrete-tabs.json

Installs from the Watermelon UI registry through the shadcn CLI. Needs Tailwind CSS and the motion package, which the command adds for you.

import { DiscreteTabs } from '../discrete-tabs';
import { FaBell } from 'react-icons/fa6';
import { HiCalendarDays } from 'react-icons/hi2';
import { MdMailOutline } from 'react-icons/md'; 



const tabs = [
  {
    id: 'mail',
    icon: <MdMailOutline size={24} />,
    label: 'Inbox',
    activeColor: 'text-blue-500',
  },
  {
    id: 'planner',
    icon: <HiCalendarDays size={24} />,
    label: 'Planner',
    activeColor: 'text-yellow-500',
  },
  {
    id: 'mail2',
    icon: <FaBell size={24} />,
    label: 'Alerts',
    activeColor: 'text-red-500',
  },
];

function DiscreteTabsDemo() {
  return (
    <div className="flex  flex-col items-center justify-center gap-10 bg-transparent p-10">
      <DiscreteTabs tabs={tabs} defaultTab="mail" />
    </div>
  );
}

export default DiscreteTabsDemo;

How the discrete tabs works

Compact icon tabs: the active one widens to reveal its label while the others shrink back to icons, with a springy width 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

A React project with Tailwind CSS and the motion package. The shadcn command installs the component and its dependencies for you.

Want motion like this on your website?

We design and build custom websites with motion, 3D and SEO built in. Websites from $500.

More free components

Explore our work