Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change checkbox icon in theme

Is it possible to change the icon of the checkbox from the theme in Material UI?

props: {
        MuiButtonBase: {
            disableRipple: buttonRippleDisable
        },
        MuiButton: {
            disableElevation: buttonElevationDisable
        },
        MuiCheckbox: {
            icon: CheckCircleOutline,
        }
    }
like image 499
David Avatar asked Oct 14 '25 08:10

David


2 Answers

In MUI v5

const theme = createMuiTheme({
    components: {
        MuiCheckbox: {
            defaultProps: {
                icon: {YOUR ICON},
                checkedIcon: {YOUR ICON}
            }
           
        }
    }
});
like image 111
Tony King Avatar answered Oct 17 '25 20:10

Tony King


yes. pass the icon in props object in theme as you've done above.

const theme = createMuiTheme({
    props:{
        MuiCheckbox:{
            icon: <FavoriteBorder />,
            checkedIcon:<Favorite />
        }
    }
});

Now wherever you use the checkbox in the scope of this theme, you'll get this icon by default.

Working demo:
Edit empty-fog-wjvnr

like image 38
Rajiv Avatar answered Oct 17 '25 19:10

Rajiv



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!