Looking to style a ToggleButton like a button? Having trouble with an error in the console when nesting a button inside? Check out this solution:
const StyledToggleButtonGroup = withStyles((theme) => ({
grouped: {
margin: theme.spacing(0.5),
border: 'none',
},
}))(ToggleButtonGroup);
<StyledToggleButtonGroup size="medium" value={problem} exclusive onChange={handleChange}>
<ToggleButton color="red" value="technical" className={helpClasses.boxButton}>
<Button size="medium" fullWidth color="primary" variant="outlined">
{t('help.technical')}
</Button>
</ToggleButton>
</StyledToggleButtonGroup>
<DialogActions>
If you're encountering an error in the console, such as
Warning: validateDOMNesting(...): <button> cannot appear as a descendant of <button>
, here's a workaround.
Here's how you can achieve the desired look: https://i.sstatic.net/ezPOr.png