Animated Tabs for React
Animated tabs for React are a Base UI tab list where a glass pill slides to the active tab, driven by the indicator variables, with full arrow-key support.
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/tabs.jsonVisits 12.4k (+8.2%), signups 684 (+3.1%), uptime 99.98%.
TabsTabsTabTabsListTabsPanel- +2 more
Basic
Overview
Workspace stats and recent activity.
import { GlassCard } from "@/components/sheenui/glass-card/glass-card";
import { Tabs, TabsList, TabsPanel, TabsTab } from "@/components/sheenui/tabs/tabs";
// Package build (after the first npm release, or a packed tarball): import { GlassCard, Tabs, TabsList, TabsPanel, TabsTab } from "@sheenui/theme";
// This example also uses glass-card: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/glass-card.json
const panels = [
["overview", "Overview", "Workspace stats and recent activity."],
["projects", "Projects", "Milestones, owners and deadlines."],
["settings", "Settings", "Profile, billing and preferences."],
] as const;
export function Example() {
return (
<Tabs defaultValue="overview" className="w-full max-w-md">
<TabsList>
{panels.map(([value, label]) => (
<TabsTab key={value} value={value}>
{label}
</TabsTab>
))}
</TabsList>
{panels.map(([value, label, body]) => (
<TabsPanel key={value} value={value}>
<GlassCard level={2} className="p-5">
<h3 className="font-semibold">{label}</h3>
<p className="mt-1 text-sm text-sheen-fg-muted">{body}</p>
</GlassCard>
</TabsPanel>
))}
</Tabs>
);
}Files to copy
4 folders · 6 files · 3 packages
- From
theme/src/ components/tabs/hooks/{use-direction.ts, use-latest.ts, use-media-query.ts, use-preferences.ts}lib/{cn.ts, form.ts}styles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/tabs.jsonRegistry item: tabs. The styles need the Tailwind v4 glass UI setup.- The examples also use
components/glass-card/motion/light-follower.tslib/heading.ts
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/glass-card.json- Packages
pnpm add @base-ui/react clsx tailwind-merge
More tabs than room
When the tabs don't fit, the track scrolls sideways instead of clipping: swipe or shift-scroll it, and tabs snap into place. The edges fade only where more tabs are hiding, and choosing a tab (or arrowing to it) scrolls it fully into view. The pill stays on its tab while the track scrolls.
Billing
The billing panel.
import { GlassCard } from "@/components/sheenui/glass-card/glass-card";
import { Tabs, TabsList, TabsPanel, TabsTab } from "@/components/sheenui/tabs/tabs";
// Package build (after the first npm release, or a packed tarball): import { GlassCard, Tabs, TabsList, TabsPanel, TabsTab } from "@sheenui/theme";
// This example also uses glass-card: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/glass-card.json
const manyTabs = ["Overview", "Projects", "Members", "Billing", "Integrations", "Security", "Settings"];
export function Example() {
// Nothing to configure: TabsList scrolls on its own when it overflows.
return (
<Tabs defaultValue="billing" className="w-full max-w-xs">
<TabsList aria-label="Workspace">
{manyTabs.map((label) => (
<TabsTab key={label} value={label.toLowerCase()}>
{label}
</TabsTab>
))}
</TabsList>
{manyTabs.map((label) => (
<TabsPanel key={label} value={label.toLowerCase()}>
<GlassCard level={2} className="p-5">
<h3 className="font-semibold">{label}</h3>
<p className="mt-1 text-sm text-sheen-fg-muted">The {label.toLowerCase()} panel.</p>
</GlassCard>
</TabsPanel>
))}
</Tabs>
);
}Morphing tabs
With morph on TabsList, tabs that carry an icon collapse to just the icon, and the active tab grows to reveal its label as the pill glides over. Tabs without an icon keep their label.
Overview
Workspace stats and recent activity.
import { Folder as FolderIcon, House as HomeIcon, Settings as GearIcon } from "lucide-react";
import { GlassCard } from "@/components/sheenui/glass-card/glass-card";
import { Tabs, TabsList, TabsPanel, TabsTab } from "@/components/sheenui/tabs/tabs";
// Package build (after the first npm release, or a packed tarball): import { GlassCard, Tabs, TabsList, TabsPanel, TabsTab } from "@sheenui/theme";
// This example also uses glass-card: npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/glass-card.json
const panels = [
["overview", "Overview", "Workspace stats and recent activity."],
["projects", "Projects", "Milestones, owners and deadlines."],
["settings", "Settings", "Profile, billing and preferences."],
] as const;
export function Example() {
return (
<Tabs defaultValue="overview" className="w-full max-w-md">
<TabsList morph aria-label="Workspace">
<TabsTab value="overview" icon={<HomeIcon />}>
Overview
</TabsTab>
<TabsTab value="projects" icon={<FolderIcon />}>
Projects
</TabsTab>
<TabsTab value="settings" icon={<GearIcon />}>
Settings
</TabsTab>
</TabsList>
{panels.map(([value, label, body]) => (
<TabsPanel key={value} value={value}>
<GlassCard level={2} className="p-5">
<h3 className="font-semibold">{label}</h3>
<p className="mt-1 text-sm text-sheen-fg-muted">{body}</p>
</GlassCard>
</TabsPanel>
))}
</Tabs>
);
}Props
Keyboard
Accessibility
- role="tablist", tab and tabpanel with aria-selected and aria-controls from Base UI; name the list with aria-label.
- When the tabs do not fit, the list scrolls sideways and a focused tab is scrolled into view.
- The gliding pill is decorative: the active tab is announced through aria-selected. Under reduced motion the pill jumps instead of sliding.
When to use Tabs
- Use Tabs as a React tabs component with a sliding indicator for a settings page with Profile, Billing and Security sections, where related panels share one place and the sliding glass pill shows the current section.
- Use it for a product page with Overview, Specs and Reviews, keeping a panel mounted through keepMounted when it holds state such as a half-filled form.
- Use activateOnFocus on TabsList when selection should follow keyboard focus, and the controlled value with onValueChange when the active tab should live in app state or the URL.
- Skip it when the choice changes a value, not a panel, where SegmentedControl is lighter, or when the links navigate to separate pages, where VerticalNav or Navbar fit better.
- Pair it with GlassCard for the panel content, Badge for counts inside a tab label, and Select on narrow screens when you have more sections than fit.
Frequently asked questions
Related pages
Guides that cover it
67 components pages in all: browse them on All components.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .