// components/ui/ButtonGroup.tsx 'use client' import * as React from 'react' type Size = 'sm' | 'md' | 'lg' export type ButtonGroupItem = { id: string label?: React.ReactNode // optional (für icon-only) icon?: React.ReactNode srLabel?: string // für icon-only (Screenreader) disabled?: boolean } export type ButtonGroupProps = { items: ButtonGroupItem[] value: string onChange: (id: string) => void size?: Size className?: string ariaLabel?: string } function cn(...parts: Array) { return parts.filter(Boolean).join(' ') } const sizeMap: Record = { sm: { btn: 'px-2.5 py-1.5 text-sm', icon: 'size-5', iconOnly: 'h-9 w-9' }, md: { btn: 'px-3 py-2 text-sm', icon: 'size-5', iconOnly: 'h-10 w-10' }, lg: { btn: 'px-3.5 py-2.5 text-sm', icon: 'size-5', iconOnly: 'h-11 w-11' }, } export default function ButtonGroup({ items, value, onChange, size = 'md', className, ariaLabel = 'Optionen', }: ButtonGroupProps) { const s = sizeMap[size] return ( {items.map((it, idx) => { const active = it.id === value const isFirst = idx === 0 const isLast = idx === items.length - 1 const iconOnly = !it.label && !!it.icon return ( ) })} ) }