Reputation: 5308
How can I change the background color of an active checkbox when using material-ui.com-framework? The style-property has no effect on the svg-color of the checkbox.
<Checkbox
label="Simple"
style={styles.checkbox}
/>
Upvotes: 0
Views: 6255
Reputation: 672
If someone is still finding the solution, here is it how it's done.
<CheckBox/>
component.<CheckBox
color = "primary"
/>
.my-checkbox-wrapper .MuiCheckbox-colorPrimary{
color: 'green';
}
Upvotes: 0
Reputation: 2684
According to the docs you can style the components in this way using themes.
You can use predefined themes, or create a custom theme. For example, achieving what you want can be as simple as :
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
import Checkbox from 'material-ui/Checkbox';
const myTheme = getMuiTheme({
checkbox: { checkedColor: 'red' }
});
and then, in the render function you can use the themeProvider
and pass in your custom theme.This will extend the base theme with the keys you have changed.
render() {
return (
<MuiThemeProvider theme={myTheme}>
<Checkbox />
</MuiThemeProvider>
);
}
Upvotes: 1