Skip to content

Animated Tabs

Motion

Tabs with a sliding pill indicator and panels that fade in the direction of travel. Full WAI-ARIA tabs keyboard support with Arrow keys, Home and End.

src/registry/premium/animated-tabs.tsx/r/animated-tabs.json

Installation

bash
npx shadcn@latest add @minidev/animated-tabs

MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/animated-tabs.json

Usage

tsx
import { AnimatedTabs } from "@/components/ui/animated-tabs"

export function Example() {
  return (
    <AnimatedTabs />
  )
}

API reference

AnimatedTabs props
PropTypeDefault
tabsTab[]DEMO
valueActive tab id when controlled.string-
defaultValueInitial tab id when uncontrolled. Defaults to the first tab.string-
onValueChangeCalled with the new tab id on click or arrow key.(id: string) => void-
labelAccessible name of the tab list.string"Sections"
classNamestring-

When to use

Follows the WAI-ARIA tabs pattern: roving focus, Arrow keys, Home and End, automatic activation. Pass tabs as data (id, label, content). Works uncontrolled (defaultValue) or controlled (value + onValueChange). Use it for a marketing or overview panel with a few views; for app navigation tabs built from parts use Tabs, and for a compact toggle between options use SegmentedControl.

Keyboard interactions

Keyboard interactions
KeyAction
ArrowRightorArrowLeftMoves focus to the next or previous tab and selects it. Wraps at both ends.
HomeorEndSelects the first or last tab.
TabMoves focus from the selected tab into the panel.

Accessibility

  • The list has role="tablist" and aria-label from label (default "Sections"). Each tab is a <button role="tab"> with aria-selected and aria-controls, and only the selected tab has tabIndex={0}.
  • The panel has role="tabpanel", aria-labelledby pointing at its tab and tabIndex={0}, so keyboard users can reach text-only panels.
  • With reduced motion the pill jumps instead of sliding, and the panel swaps with no slide, blur or delay.

Frequently asked questions

How is AnimatedTabs different from Tabs?

AnimatedTabs takes one tabs array of { id, label, content } and selects a tab as soon as an arrow key reaches it. Tabs is built from parts on Base UI, where arrow keys only move focus until you press Enter or Space (unless you set activateOnFocus), and it supports vertical orientation and count badges.

How do I control which tab is open?

Pass value and onValueChange. onValueChange fires with the new id only when it differs from the current one. If value matches no tab, the first tab is shown instead of an empty panel.

Why does a form in another tab lose what I typed?

Only the active panel is rendered; switching tabs unmounts the old one. Keep the form state above AnimatedTabs, or use Tabs with keepMounted on TabsContent.

Dependencies

npm

motion

Built from

No other MiniDev files

Examples

Custom tabs

Each tab is an id, a label and any content node; the pill slides and the panel fades toward the direction of travel.

Default tab and change handler

defaultValue picks the starting tab and onValueChange reports the id, which is enough to sync the tab with the URL.

Rich panel content

Panels take whole components, so a record view can switch between a description list and usage bars.

All navigation components

Learn more