import clsx from 'clsx' import Link from 'next/link' import { ReactNode, useState } from 'react' import { Row } from './row' 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 }) { const { tabs, defaultIndex, labelClassName, onClick } = props const [activeIndex, setActiveIndex] = useState(defaultIndex ?? 0) const activeTab = tabs[activeIndex] as Tab | undefined // can be undefined in weird case return ( <>
{activeTab?.content} ) }