Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I customize the color of a Checkbox in MUI?

I am using MUI in my project, and I have a Checkbox within a div with a black background. But it doesn't look good because the Checkbox is black too. How can I change the color of the Checkbox from black to another color?

like image 935
kellyxiepei Avatar asked Dec 26 '16 14:12

kellyxiepei


People also ask

How do I customize a checkbox in MUI?

import { withStyles } from '@material-ui/core/styles'; import Checkbox from '@material-ui/core/Checkbox'; const checkBoxStyles = theme => ({ root: { '&$checked': { color: '#3D70B2', }, }, checked: {}, }) const CustomCheckbox = withStyles(checkBoxStyles)(Checkbox);

How do I change the color of a checkbox?

“:hover” is used to style the checkbox when user hovers over it. Notice that when the mouse pointer move over the checkbox the color of it changes to yellow. “:active” is used to style the checkbox when it is active. Notice that when click the checkbox it will first notice a red color and then the green color.

How do I change the color of checkbox when checked in react?

To customize the color of a checkbox in React Material UI, we can set the style prop to an object with the color we want. We set the style prop of the Checkbox to an object with the color of the checkbox. Next, we set the label color by setting the style prop to an object with the color of the label.


1 Answers

This is how you do it:

 <FormControlLabel                   control={                   <Checkbox                     checked={cryon}                     onChange={this.handleChange('cryon')}                     style ={{                       color: "#00e676",                     }}                     value="cryon"                   />                 }                 label={<Typography variant="h6" style={{ color: '#2979ff' }}>Work</Typography>}               /> 

enter image description here

like image 196
Hitesh Sahu Avatar answered Sep 23 '22 13:09

Hitesh Sahu