import { CSSProperties, ReactNode, useState } from "react"; import "./Tabs.css"; export type Tab = { header: ReactNode; content: ReactNode; }; type TabsProps = { tabs: Tab[]; initialIndex?: number; onTabChange?: (index: number) => void; }; const contentStyles: Record = { activeLeft: { borderTopLeftRadius: 0 }, activeRight: { borderTopRightRadius: 0 }, } as const; const Tabs = ({ tabs, initialIndex = 0, onTabChange }: TabsProps) => { const [activeIndex, setActiveIndex] = useState( !!tabs[initialIndex] ? initialIndex : 0 ); return (
{tabs.map((tab, i) => ( ))}
{tabs[activeIndex]?.content}
); }; export default Tabs;