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 (<MagnetTabsslug="my-tabs"options={["All", "Latest", "Popular", "Featured"]}activeTab={activeTab}onSelect={setActiveTab}/>)}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| slug | string | - | Unique ID for animations |
| options | string[] | - | Array of tab labels |
| activeTab | string | - | Currently selected tab |
| onSelect | (option: string) => void | - | Callback when selected |
Last updated on