我的问题很简单,如何添加检查图标内选定的ToggleButton?堆栈流不会让我张贴它,我只是没有其他解释pleaseee
export default function TableBusiness() {
const [alignment, setAlignment] = React.useState('web');
const handleChange = (event, newAlignment) => {
setAlignment(newAlignment);
};
return (
<Box
sx={{
p: 2,
display: 'flex',
flexWrap: 'wrap',
'& > :not(style)': {
width: "100%",
height: 1000,
},
}}
>
<Box
display="flex"
justifyContent="space-around"
>
<ToggleButtonGroup
color="primary"
sx={{ borderRadius: '40px !important', backgroundColor: grey[50]}}
value={alignment}
exclusive
onChange={handleChange}
aria-label="Platform"
>
<ToggleButton sx={{borderBottomLeftRadius:20 , borderTopLeftRadius:20}} value="one">از ابتدای تاسیس</ToggleButton>
<ToggleButton borderRadius= '30px' value="two">یکسال گذشته</ToggleButton>
<ToggleButton value="three">یکماه گذشته</ToggleButton>
<ToggleButton sx={{borderBottomRightRadius:20 , borderTopRightRadius:20}} value="four">جدیدترین</ToggleButton>
</ToggleButtonGroup>
</Box>
);
}
我希望在每个选定ToggleButton左侧看到复选标记
1条答案
按热度按时间6jjcrrmo1#
只需检查ToggleButton的值是否与“alignment”中选择的值相对应。类似于: