0
votes

I am using material ui checkbox, i wanted it to have its own background color over my div which has colored background. I have set the root to have a backgroundColor as white but the svgicon is a round shape which is not the look i intend to have. Can i shape the checkbox ?

Already have tried many things but not able to figure out how to change the icon

const styles = {
    root : {
        padding : '0px',
        display : 'inline-block',
        backgroundColor : 'white'
    },
    formLabelRoot : {
        margin : '0'
    }
}
.
.
.
render () {
        const { classes } = this.props
        return(
            <div style={customStyles.divStyle}>
                <div style={customStyles.div1}>
                    <FormControlLabel
                        classes={{root: classes.formLabelRoot}}
                        control={
                            <Checkbox
                                classes={{root : classes.root }}
                                color='primary'
                            />
                            }
                        label={''}
                    />
                </div>

The background white is making a spherical rounded checkbox apparent

Image of what is happening now

2
What color do you want the checkbox to be? Do you want it to be white? You'd need to the set the backgroundColor/background of the checkbox to match the background of the wrapping div/element. codesandbox.io/embed/material-demo-rp2wuAlexander Staroselsky
I have solved this issue. I will update this answerNewBEE

2 Answers

0
votes

You can override the icons used for the checked and unchecked states. The props you're looking for are icon for the unchecked state and checkedIcon for the checked state. Both of which take a component to be used as the icon.

Documentation here

0
votes

You might have to make a compromise here if you don't want to go making your own icons. Something like this is possible without changing the icons. If you're looking for a solid white box with a grey outline as the unchecked box, you might have to provide that svg yourself because I don't see anything like it in @material-ui/icons.

enter image description here

If this IS something you're ok with then target the svg, and give it a fill: "white".