React Fluent UI - Change color of checkbox's checked mark and label

Ankit Saxena

I've a react app using Fluent UI. I'm using <Checkbox/> component but it's having it's default colors and behavious. Like this:

enter image description here

I want to change the color of the checked mark and also the label (Green checked mark and brown lable). I tried the below way to do so but it didn't work.

const checkBoxStyles = {
  root: {
    color: 'brown'
  },
  checkbox: {
    color:'green'
  }
}
  return (
    <Stack tokens={stackTokens}>
      <Checkbox
        styles={checkBoxStyles}
        label="Controlled checkbox"
        checked={isChecked}
        onChange={onChange}
      />
    </Stack>
  );
};

Full working code at codepen - https://codepen.io/AnkitSaxena2605/pen/eYyppLj

A.A coder

Try to do the following changes in your checkBoxStyles:

 const checkBoxStyles = {
    checkmark: {
      background: 'green',
      color: 'white'
    },
    checkbox: {
      background: 'white',
      borderColor: 'black'
    },
    text: {
      fontWeight: "bold",
      color:'brown'
    }
  };

checkbox and checkmark are for styling the checkbox and text is for styling the label.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324243746&siteId=291194637