Back to Components

Floating Tabs

A modern tab navigation component featuring a fluid animated background indicator that smoothly transitions between active tabs with spring physics.

Preview

Loading...

Installation

Install the component using the CLI.

$npx shadcn@latest add https://ankurz.me/r/floating-tabs.json

Usage

Import the component:

import { FloatingTabs } from "@/components/floating-tabs"

Use it in your code:

<FloatingTabs 
  defaultValue="tab1"
  tabs={[
    { value: "tab1", label: "Tab 1" },
    { value: "tab2", label: "Tab 2" }
  ]}
/>

Props

PropertyTypeDefaultDescription
tabs*array-Array of tab objects with value, label, and content properties.
defaultValuestringtabs[0].valueThe default active tab value.
onChangefunctionundefinedCallback function called when tab changes. Receives the new tab value.
classNamestring""Additional CSS classes to apply to the container.