Skip to documentation content

Animated Tabs

Tabs whose active indicator springs between triggers as a raised pill or an underline.

animated-tabs-demo

Overview

Animated Tabs pairs Base UI Tabs with a shared-layout indicator. The indicator lives inside the active tab and carries one layout id per list, so it springs to the next tab whether the change comes from a click, a tap, or the keyboard. Panel content fades in when its tab becomes active. Use the pill variant for compact segmented controls and underline for section navigation.

Installation

npx honestui@latest add animated-tabs

Usage

import {
  AnimatedTabs,
  AnimatedTabsList,
  AnimatedTabsPanel,
  AnimatedTabsTab,
} from "@/components/animated/animated-tabs"

<AnimatedTabs defaultValue="overview">
  <AnimatedTabsList aria-label="Dashboard sections">
    <AnimatedTabsTab value="overview">Overview</AnimatedTabsTab>
    <AnimatedTabsTab value="analytics">Analytics</AnimatedTabsTab>
  </AnimatedTabsList>
  <AnimatedTabsPanel value="overview">…</AnimatedTabsPanel>
  <AnimatedTabsPanel value="analytics">…</AnimatedTabsPanel>
</AnimatedTabs>

Give AnimatedTabs a defaultValue or value that matches one of the tab values.

Accessibility

Roles, selection state, and keyboard support come from Base UI Tabs: the list is a tablist, arrow keys move between tabs, and each panel is labelled by its tab. Name the list with aria-label when there is no visible heading. The indicator is decorative and hidden from assistive technology. With reduced motion enabled, the indicator fades to the new tab instead of sliding.

API Reference

PropTypeDefaultDescription
value / defaultValuestring | number–Selected tab on AnimatedTabs, controlled or initial.
onValueChange(value) => void–Called when the selected tab changes.
variantpill|underline"pill"Indicator style, on AnimatedTabsList.
indicatorClassNamestring–Classes for the moving indicator.
transitionTransitionSPRING_LAYOUTSpring or tween for the indicator.
value*string | number–Value of an AnimatedTabsTab and its AnimatedTabsPanel.

AnimatedTabs, AnimatedTabsList, AnimatedTabsTab, and AnimatedTabsPanel also accept the props of Base UI's Tabs.Root, Tabs.List, Tabs.Tab, and Tabs.Panel.