0

Is it possible add custom objects to the "createMuiTheme"? Lets say I have a cart icon in the AppBar, can I some how inject this so that it is available in the "createMuiTheme"?

Something like this:

const theme = createMuiTheme({
    custom: {
        CartIcon: {
            color: "#333"
        }
    }
});
David
  • 141
  • 9

1 Answers1

0

yes. a custom object can be added in MUI theme object.
You've added the custom CartIcon color in the object, now you can access that object inside the makeStyles in this way:-

const useStyles = makeStyles((theme) => ({
    cartClass:{
      color:theme.custom.CartIcon.color;
    }
}));
Rajiv
  • 3,346
  • 2
  • 12
  • 27