Skip to content

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.json

Visits 12.4k (+8.2%), signups 684 (+3.1%), uptime 99.98%.

Basic

Overview

Workspace stats and recent activity.

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.ts
  • lib/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.

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.

Props

PropTypeDefaultDescription
Tabs value / defaultValuestringNoneSets the active tab (controlled or uncontrolled).
Tabs onValueChange(value) => voidNoneCalled when the active tab changes.
TabsList classNamestringNoneStyles the glass track. Other props (aria-label, activateOnFocus, ...) go to the tablist itself.
TabsList activateOnFocusbooleanfalseActivate tabs as arrow keys move focus (otherwise Enter / Space).
TabsList morphbooleanfalseTabs with an icon collapse to just the icon; the active tab grows to show its label.
TabsTab valuestringNoneMatches a TabsPanel value.
TabsTab iconReactNodeNoneA decorative glyph before the label (aria-hidden). With morph on the list, the label shows only while the tab is active.
TabsTab disabledbooleanfalseDisables this tab so it cannot be selected.
TabsPanel valuestringNoneShown when its tab is active.
Tabs ...propsBase UI propsNoneThe rest is passed to the underlying Base UI part (for example orientation, style, className, render).
TabsList ...propsBase UI propsNoneThe rest is passed to the underlying Base UI part (for example style, render, loopFocus).
TabsTab ...propsBase UI propsNoneThe rest is passed to the underlying Base UI part (for example style, className, render, nativeButton).
TabsPanel ...propsBase UI propsNoneThe rest is passed to the underlying Base UI part (for example style, className, render, keepMounted).

Keyboard

KeysAction
TabEnter the tab list once (on the active tab); the next Tab moves to the panel.
Arrow Left/Arrow RightMove focus between tabs (Arrow Up / Down when vertical).
Home/EndJump to the first or last tab.
Enter/SpaceActivate the focused tab (set activateOnFocus on TabsList to activate as focus moves).

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

67 components pages in all: browse them on All components.

By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .