Components

React component for shadcn/ui

Animated Tabs for React and shadcn/ui

An accessible animated tabs component for React and shadcn/ui with a fluid Motion shared-layout indicator and keyboard navigation.

Loading…

Animated Tabs is a copy-and-paste React component for switching between segmented views with a spring-animated active indicator. It works with shadcn/ui projects, supports controlled and uncontrolled state, and uses Motion shared-layout animation so the indicator moves smoothly between options.

Features

  • Animates a single shared indicator instead of remounting one per option.
  • Supports controlled and uncontrolled selection.
  • Includes arrow-key, Home, and End navigation with roving focus.
  • Respects the user's reduced-motion preference.

Installation

pnpm dlx shadcn@latest add @tentui/animated-tabs

Usage

import { AnimatedTabs } from "@/components/animated-tabs";
const tabs = [
  { value: "overview", label: "Overview" },
  { value: "analytics", label: "Analytics" },
];
 
<AnimatedTabs
  tabs={tabs}
  value={value}
  onValueChange={setValue}
  aria-label="Dashboard view"
/>

The component supports controlled and uncontrolled state with accessible radio-group semantics. Arrow keys, Home, and End move focus and selection through the options.

Render the matching content panel from the selected value. Animated Tabs manages the segmented control and its selection state; it does not impose a content panel structure on your application.

Accessibility

The control uses radio-group semantics because selecting an option updates the current view immediately. The active option is the only item in the tab order, while arrow keys move focus and selection together. A visible focus ring remains available for keyboard users.

Motion's reduced-motion configuration disables the shared-layout movement when the user requests less animation. For more implementation patterns, read How to Add Animations to shadcn/ui Components.

API reference

PropType

FAQ

How do I install the Animated Tabs with shadcn?

Run npx shadcn@latest add @tentui/animated-tabs after adding the @tentui registry to components.json (installation guide), or run npx shadcn@latest add https://tentui.com/r/animated-tabs.json without it. The CLI copies animated-tabs.tsx into your project and installs motion.

Can I control the active tab from state?

Yes. Pass value and onValueChange to control it, or defaultValue to let the component manage it; without either, the first tab starts active. In both modes onValueChange fires with the new tab's value.

Are the Animated Tabs keyboard accessible?

Yes. The control is a radiogroup with one tab stop on the active option, and the arrow keys, Home, and End move focus and selection together. Name it with aria-label or aria-labelledby, since the group has no visible label.

Does it render the tab panels?

No. Animated Tabs is the segmented control only, so render the matching content yourself from the selected value, for example by keeping it in state and switching on it.

How does the sliding indicator work, and can I turn it off?

One Motion element with a shared layoutId springs to the selected option, while keyboard selection moves it instantly. With reduced motion enabled in the operating system, Motion skips the slide; each instance generates its own layoutId, so several tab bars on a page don't interfere.

Is TentUI's Animated Tabs component free?

Yes. Animated Tabs is free and source-available: the shadcn CLI copies its source into your project, and you can use it in unlimited personal and client projects under the TentUI License. The license doesn't allow redistributing or reselling the component itself.

All guides

Used in blocks

All blocks