How change Checkbox body styles depeding of its input state at Mantine?

177 views Asked by At

I'm using Mantine and have to implement a specific styled container for Checkbox input.

This checkbox will change its body styles depending of the input state(checked or not checked). Therefore, to change checkbox' container body style, I need to know the checkbox' input pseudo class state.

Inside the theme file. I have something like this:

Checkbox: {
      styles: theme => ({
        body: {
          background: "white",
        },
        "input:checked": {
          body: {
            background: "black",
          }
        },
      }),
    },

This body and input value comes from StylesAPI from Mantine:

enter image description here

Any idea how can I achieve this?

Thank you in advance!

1

There are 1 answers

1
mertk On

Can you try this one:

Checkbox: {
  styles: theme => ({
    body: {
      background: "white",
    },
    input: {
      "&:checked": {
        background: "black",
      }
    },
  }),
},