import clsx from 'clsx' import Link from 'next/link' import { ReactNode, useState } from 'react' import { Row } from './row' import { track } from '@amplitude/analytics-browser' type Tab = { title: string tabIcon?: ReactNode content: ReactNode // If set, change the url to this href when the tab is selected href?: string } export function Tabs(props: { tabs: Tab[] defaultIndex?: number labelClassName?: string onClick?: (tabTitle: string, index: number) => void className?: string currentPageForAnalytics?: string }) { const { tabs, defaultIndex, labelClassName, onClick, className, currentPageForAnalytics, } = props const [activeIndex, setActiveIndex] = useState(defaultIndex ?? 0) const activeTab = tabs[activeIndex] as Tab | undefined // can be undefined in weird case return ( <>
{activeTab?.content} ) }