import { ToggleButton, ToggleButtonGroup, type SxProps, type Theme } from '@mui/material'; export interface SwitchOption { value: T; label: React.ReactNode; } export interface SwitchButtonGroupProps { value: T; options: SwitchOption[]; onChange: (value: T) => void; sx?: SxProps; size?: 'small' | 'medium' | 'large'; buttonSx?: SxProps; } export default function SwitchButtonGroup({ value, options, onChange, sx, size, buttonSx, }: SwitchButtonGroupProps) { return ( v && onChange(v)} sx={{ width: '100%', mb: 2, borderRadius: 4, bgcolor: (theme: Theme) => (theme.palette.mode === 'light' ? 'grey.100' : 'grey.900'), border: '1px solid', borderColor: 'divider', p: 0.6, '& .MuiToggleButtonGroup-grouped': { flex: 1, border: 'none', borderRadius: 3.5, mx: 0.3, fontWeight: 800, color: 'text.secondary', transition: 'color 0.3s', '&:not(:first-of-type)': { borderLeft: 'none', marginLeft: 0.6, }, '&.Mui-selected': { bgcolor: 'background.paper', color: 'primary.main', boxShadow: '0 4px 12px rgba(0,0,0,0.05)', }, }, ...sx, }} > {options.map((option) => ( {option.label} ))} ); }