Skip to content

NewMCP server for your coding agent. Set it up ›

Nexus UI
Get Pro

Animated Tabs, animated React component

A settings panel with a sliding segmented control: rows slide in from the side you moved towards, the panel resizes to fit, and each row has an iOS-style switch whose knob stretches while pressed.

  • Free
  • Inputs & Controls
  • Spring

Ticks when you change tab, latches on and off on the switches, pops on a new document tab, swipes on close and thumps when you drop a dragged tab. Sound is off on this site until you switch it on.

Animated Tabs

Elastic Tabs

Document Tabs

Like Animated Tabs? 301 more are in Pro.

Pro unlocks all 301 Pro components, every template and block, and everything we release next. Animated Tabs stays free.

Props

PropTypeDefaultWhat it does
accent"#34c759"Colour of a switch that is on.
autoplayfalseFlips switches and changes tabs until someone interacts.
ElasticTabs.tabsfour dashboard tabsThe tabs: an id, a label and the content shown in the panel.
ElasticTabs.label"Dashboard"Accessible name for the tab list.
ElasticTabs.onChangeundefinedCalled with the tab id whenever the selected tab changes.
ElasticTabs.autoplayfalseSteps through the tabs every 2.4s until someone touches the component. Never runs under reduced motion and pauses when off screen.
ElasticTabs.className""Extra classes for the card.
DocumentTabs.initialTabsthree demo tabsThe tabs it starts with (id, title, url, color, letter). Closing the last tab brings these back.
DocumentTabs.onActiveChangeundefinedCalled with the tab id when the active tab changes.
DocumentTabs.autoplayfalseOpens, switches, reorders and closes tabs on a loop until someone touches the component. Never runs under reduced motion and pauses when off screen.
DocumentTabs.className""Extra classes for the window.
enableSoundtruePlays interface sounds on interaction. They follow the sound switch (setSoundsEnabled, on by default) and stay silent on hover. Autoplay makes the same sounds once the visitor has used the page. Pass false to silence this component.

Add it to your project

  1. 1

    Set up your project once

    You need a Next.js project with Tailwind CSS and the @/ import alias. In its root folder, run this once. It creates components.json and the cn() helper in src/lib/utils.ts:

    npx shadcn@latest init -d

    Starting from nothing? The Quick Start walks through the whole thing.

  2. 2

    Connect the registry

    Run this once per project. It writes the Nexus UI entry into components.json for you:

    npx shadcn@latest registry add "@nexus-labs=https://www.nexus-ui.com/api/registry/{name}"

    Type it exactly as shown. {name} is filled in by the CLI with the component you ask for, so you never replace it.

  1. 3

    Add the component

    Run this from your project root. It adds the component, the helpers it imports and its npm packages.

    npx shadcn@latest add @nexus-labs/animated-tabs
  2. 4

    Check what was added

    With a project made as in the Quick Start (a src/ folder), these files land in it:

    components/
    animated-tabs/
    animated-tabs.tsx
    document-tabs.tsx
    elastic-tabs.tsx
    index.ts
  3. 5

    Copying by hand? Skip the registry

    Instead of steps 2 and 3 you can copy the files yourself, with no registry and no API key. Step 1 still applies, so that cn() exists. Install the packages:

    npm install framer-motion

    Then show the source and create each file at the path it gives:

  4. 6

    Use it in a page

    Installing only adds the files. Import the component in a page and render it. The Usage tab on the preview shows a fuller example with props:

    // src/app/page.tsx
    import { AnimatedTabs, Switch } from "@/components/animated-tabs";
    
    export default function Page() {
      return (
        <main>
          <AnimatedTabs />
        </main>
      );
    }

Like Animated Tabs? 301 more are in Pro.

Pro unlocks all 301 Pro components, every template and block, and everything we release next. Animated Tabs stays free.

Animated Tabs questions

How do I install Animated Tabs?

Run `npx shadcn@latest add @nexus-labs/animated-tabs`. It is free and installs framer-motion. The install adds `AnimatedTabs`, `Switch`, `ElasticTabs` and `DocumentTabs`.

What is the difference between AnimatedTabs, ElasticTabs and DocumentTabs?

`AnimatedTabs` is a fixed settings panel with switches (props `accent` and `autoplay`). `ElasticTabs` is a stretchy-pill tab bar for your own content. `DocumentTabs` is a browser-style strip. `Switch` is exported on its own too.

How do I give ElasticTabs my own tabs?

Pass `tabs` as `{ id, label, content }` items, where `content` is any React node. `label` names the tab list (default "Dashboard") and `onChange` receives the tab id. Left, Right, Home and End move between tabs.

How do I reorder and close DocumentTabs?

Drag a tab to reorder it. On a focused tab, Alt with an arrow moves it, Delete or Backspace closes it, and plain arrows switch tabs. It holds at most 6 tabs, and closing the last one restores `initialTabs`.

How does it handle reduced motion?

`ElasticTabs` and `DocumentTabs` check it: their `autoplay` never runs, and the pill and panel stop springing or sliding. `AnimatedTabs` and `Switch` do not check it.

Does it make sound, and how do I turn it off?

Ticks when you change tab, latches on and off on the switches, pops on a new document tab, swipes on close and thumps when you drop a dragged tab. Sounds are synthesised with the Web Audio API, so there are no audio files, and they only play after a click or key press. Pass `enableSound={false}` to silence this component, or call `setSoundsEnabled(false)` from `@/lib/ui-sounds` to switch every sound off at once. The CLI installs `@/lib/ui-sounds` with the component.

Guides