user10972884
user10972884

Reputation:

material ui change the checkbox color

https://codesandbox.io/s/m7z2l1j09y

const theme = createMuiTheme({
  palette: {
    secondary: {
      main: "#E33E7F"
    },

    formControl: {
      color: "black"
    }
  }
});

<MuiThemeProvider theme={theme}>
          <FormControl component="fieldset" className={classes.formControl}>
            <FormLabel component="legend">Gender</FormLabel>
            <RadioGroup
              aria-label="Gender"
              name="gender1"
              className={classes.group}
              value={this.state.value}
              onChange={this.handleChange}
            >
              {radioValues.map(radio => {
                return (
                  <FormControlLabel
                    value={radio.value}
                    control={<Radio />}
                    label={radio.label}
                  />
                );
              })}
            </RadioGroup>
            {checkBoxvalues.map((check, index) => {
              return (
                <FormControlLabel
                  key={check.value}
                  control={
                    <Checkbox
                      checked={check.checked}
                      onChange={this.handleCheckBoxChange(check.value, index)}
                      value={check.value}
                    />
                  }
                  label={check.label}
                />
              );
            })}
          </FormControl>
        </MuiThemeProvider>

Upvotes: 2

Views: 7007

Answers (1)

Ryan Cogswell
Ryan Cogswell

Reputation: 80976

Your error was due to the import being incorrect. Instead of

import { MuiThemeProvider, createMuiTheme } from "material-ui/styles";

It should be

import { MuiThemeProvider, createMuiTheme } from "@material-ui/core/styles";

I also added specifying the color property on the Checkbox.

Here's a working version of your sandbox: https://codesandbox.io/s/w68nm77o0k

Upvotes: 2

Related Questions