Skip to content
Skip to Content
DocsMagnet Tabs
Magnet Tabs

Magnet Tabs

Animated tab navigation with magnetic hover effect and smooth indicator transitions.

Component preview

Install using CLI

npx shadcn@latest add "https://www.obsidianui.dev/r/magnet-tabs.json"

Install Manually

1

Install dependencies

npm install motion
2

Copy the source code

Copy the code into components/block/magnet-tabs.tsx

Usage

Code
import { MagnetTabs } from "@/components/block/magnet-tabs"
import { useState } from "react"
export function Demo() {
const [activeTab, setActiveTab] = useState("All")
return (
<MagnetTabs
slug="my-tabs"
options={["All", "Latest", "Popular", "Featured"]}
activeTab={activeTab}
onSelect={setActiveTab}
/>
)
}

Props

PropTypeDefaultDescription
slugstring-Unique ID for animations
optionsstring[]-Array of tab labels
activeTabstring-Currently selected tab
onSelect(option: string) => void-Callback when selected
Last updated on