import clsx from 'clsx'; import { ComponentProps, ReactNode } from 'react'; import { Button } from '@@/buttons'; import styles from './NavTabs.module.css'; export interface Option { label: ReactNode; children?: ReactNode; id: T; hidden?: boolean; icon?: ComponentProps['icon']; } interface Props { options: Array> | ReadonlyArray>; selectedId?: T; onSelect?(id: T): void; disabled?: boolean; type?: 'tabs' | 'pills'; justified?: boolean; } export function NavTabs({ options, selectedId, onSelect = () => {}, disabled, type = 'tabs', justified = false, }: Props) { const selected = options.find((option) => option.id === selectedId); return (
    {options.map( (option) => !option.hidden && (
  • {/* rule disabled because `nav-tabs` requires an anchor */} {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
  • ) )}
{selected && selected.children && (
{selected.children}
)}
); function handleSelect(option: Option) { if (disabled) { return; } onSelect(option.id); } }