Overview
Animated Tab is a fully controlled tab component where the active indicator is amotion.div using Framer Motion’s layoutId — the pill smoothly slides between buttons with spring physics rather than a static underline. The container uses backdrop-blur for a glassmorphism aesthetic that works in both light and dark themes.
Installation
components/rareui/AnimatedTab.tsx into your project.
Usage
Props
Array of tab descriptor objects. Each entry must include an
id: string and a label: string. Required.The
id of the currently active tab. This is a controlled prop — the parent component owns state. Required.Callback invoked with the tab
id whenever a tab is clicked. Use this to update the activeTab value in state. Required.Additional Tailwind or CSS classes applied to the outer container
<div>. Useful for constraining width or adding margin.Examples
Minimal two-tab setup
Rendering content per tab
Custom container width
Features
Spring-Animated Pill
The active indicator uses Framer Motion
layoutId so it flows between tabs with spring physics, not a fixed CSS transition.Glassmorphism Container
The tab strip uses
backdrop-blur-xl and semi-transparent backgrounds for a premium frosted-glass appearance.Hover State
Inactive tabs show a subtle highlight background on hover, also animated with Framer Motion for consistency.
Dark Mode
Active pill inverts from black to white and text colors adapt automatically in dark theme.
Controlled Component
State is owned by the parent, making it straightforward to sync tab selection with routing or other UI state.
Responsive
Tabs wrap on small screens and use responsive padding to remain usable across device widths.