Tabs.tsx 631 B

12345678910111213141516171819202122232425
  1. 'use client';
  2. import clsx from 'clsx';
  3. import { Tab as HTab } from '@headlessui/react';
  4. import { Fragment } from 'react';
  5. export function Tabs({ items, children }) {
  6. return (
  7. <HTab.Group>
  8. <HTab.List className="tabs">
  9. {items.map((item, i) => (
  10. <HTab as={Fragment} key={item}>
  11. {({ selected }) => <div className={clsx('tab', selected && 'active')}>{item}</div>}
  12. </HTab>
  13. ))}
  14. </HTab.List>
  15. <HTab.Panels>{children}</HTab.Panels>
  16. </HTab.Group>
  17. );
  18. }
  19. export function Tab({ children }) {
  20. return <HTab.Panel className="tab-content">{children}</HTab.Panel>;
  21. }