import { animate } from "motion"; import { motion } from "motion/react"; import { useMemo, useRef, useState } from "react"; import { cn } from "@/utils/cn"; export type Props = { tabs: { value: string; label: string; description?: string; icon?: React.ReactNode; children?: React.ReactNode; }[]; activeTab: string; setActiveTab: (tab: string) => void; position?: "left" | "center"; itemButtonClassName?: string; itemClassName?: string; noScroll?: boolean; }; export default function Tabs({ tabs, activeTab, setActiveTab, position = "left", itemButtonClassName, itemClassName, noScroll, }: Props) { const backgroundRef = useRef(null); const activeIndex = useMemo( () => tabs.findIndex((tab) => tab.value === activeTab), [tabs, activeTab], ); const [styles, setStyles] = useState<{ x: number; width: number; }>({ x: 0, width: 0, }); return (
{styles.width !== 0 && ( )} {tabs.map((tab, index) => (
{position === "center" && (
)}
))}
); }