Animated Tabs

A tabs component with smooth sliding indicator animations and multiple variants.

Open in v0~8.6 kB

Last updated: March 7, 2026

Installation

npx smoothui-cli add animated-tabs

Features

  • Three variants: underline, pill, and segment
  • Smooth sliding indicator animation
  • Controlled and uncontrolled modes
  • Support for icons in tabs
  • Full keyboard navigation
  • Accessible with proper ARIA attributes
  • Respects reduced motion preferences

Accessibility

Keyboard Interactions

KeyDescription
Arrow RightMoves focus and selection to the next tab (wraps to first)
Arrow LeftMoves focus and selection to the previous tab (wraps to last)
HomeMoves focus and selection to the first tab
EndMoves focus and selection to the last tab

ARIA Attributes

AttributeElementPurpose
role="tablist"ContainerIdentifies the tab group as a tablist
aria-label="Tabs"ContainerProvides an accessible name for the tablist
role="tab"Tab buttonIdentifies each button as a tab
aria-selectedTab buttonIndicates which tab is currently active
tabindexTab buttonUses roving tabindex: active tab is 0, inactive tabs are -1

Screen Reader

  • Only the active tab is in the tab order; arrow keys navigate between tabs
  • Each tab announces its selected state via aria-selected

Reduced Motion

This component respects the prefers-reduced-motion media query via useReducedMotion from Motion. When reduced motion is preferred, the sliding indicator animation between tabs is disabled instantly.

Props