import { Toggle } from '@base-ui/react/toggle'; import { ToggleGroup as BaseToggleGroup } from '@base-ui/react/toggle-group'; import clsx from 'clsx'; import { Fragment } from 'react'; import { twMerge } from '@/utils/twMerge'; export interface ToggleOption { value: T; label: React.ReactNode; 'aria-label'?: string; disabled?: boolean; } export interface ToggleGroupProps { value: T[]; onChange: (value: T[]) => void; options: ToggleOption[]; className?: string; toggleClassName?: string; disabled?: boolean; 'aria-label'?: string; multiple?: boolean; minimal?: boolean; } export default function ToggleGroup({ value, onChange, options, className, toggleClassName, disabled, 'aria-label': ariaLabel, multiple = false, minimal, }: ToggleGroupProps) { return ( {options.map((option, index) => { const isPressed = value.includes(option.value as T); const isDisabled = disabled || option.disabled; const isLast = index === options.length - 1; return ( {option.label} {!isLast && minimal && } {!isLast && !minimal && ( )} ); })} ); }