I am trying to avoid typing redundant code. In multiple components I have created the same css classes. I want to add them to the theme using createMuiTheme() and then only using the style directly from the theme without having to call "classes" props on the Component props.
I have tried creating a theme on the root Component like this:
const theme = createMuiTheme({
palette:{
primary: {
main: '#47286E',
light: '#D91677'
},
secondary: {
main: '#9156D8'
},
},
fab: {
position: "relative",
top: 0,
marginTop: 20px
textTransform: 'none',
width: 220,
height: 50
},
});
then I passed theme down to the other components using
<MuiThemeProvider theme={theme}>
I tried importing the fab button directly inside the component
<Fab variant="extended" className={this.props.theme.fab} size='small'>
Change
</Fab>
however I don't seem to get any value when I try to get fab css class. I just don't want to create a whole new
const styles = theme => {
blabbla
}
and import it in every component using the "classes" props if what I want is already on the theme being passed down to its child components.