0

Well consider the code in this question. The answer to give a style is to use something like:

import React, { Component } from 'react';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import logo from '../Assets/logo.svg';
import { withStyles } from '@material-ui/core/styles';

const styles = {
  transparentBar: {
    backgroundColor: 'transparent !important',
    boxShadow: 'none',
    paddingTop: '25px',
    color: '#FFFFFF'
  }
};

class NavigationBar extends Component {
  render() {
    return (
      <AppBar className={classes.transparentBar}>
        <Toolbar>
          <img src={logo} style={{ height: '28px' }} />
        </Toolbar>
      </AppBar>
    );
  }
}

export default withStyles(styles)(NavigationBar);

However in my case when I "use" this class I wish to "overwrite" the styles object.:

import TransparentNavigationBar from './MyNavigationBar'
const localstyles = {
    transparentBar: {
        paddingTop: '0px',
        paddingBottom: '10px',
    }
}

function SomeComponent(props) {
    //do something to inject local style definition above into TransparentNavigationBar
    return <TransparentNavigationBar/>
}

I can't seem to find any indication how this should be done.

paul23
  • 8,799
  • 12
  • 66
  • 149
  • You should take a look at the new [@material-ui/styles](https://material-ui.com/css-in-js/basics/) which is looking likely to make it into Material-UI v4 (Q1 2019). In particular the [Hook API](https://material-ui.com/css-in-js/basics/#hook-api). – MattC Dec 03 '18 at 03:34
  • Also, take a look at this related question: https://stackoverflow.com/questions/48879517/passing-props-to-material-ui-style – MattC Dec 03 '18 at 03:35

0 Answers0