Material-ui: Nesting of Overriden Themes

Created on 9 Dec 2017  路  1Comment  路  Source: mui-org/material-ui

  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior


Theme nesting is not working as expected.
In below example, "MuiInput root of theme1" and "MuiInput underline of theme2" both should work.

Current Behavior


But here "MuiInput underline of theme2" works well but it does apply properties of "MuiInput root of theme1".

Steps to Reproduce (for bugs)

import React from 'react';
import { createMuiTheme, MuiThemeProvider } from 'material-ui/styles';
import Input, { InputLabel } from 'material-ui/Input';


const theme1 = createMuiTheme({
  typography: {
      fontFamily:
        'Hind Vadodara',
      body1: {
        fontSize: 16,
      },
    },
    overrides: {
      MuiInput: {
        root: {
          fontSize: 16,
          color: 'red',
        },
      }
    },
  });

  const theme2 = outerTheme => ({
  ...outerTheme,
  overrides: {
      MuiInput: {
        underline: {
          '&::before': {
            height: 0,
          },
        },
      },
    },
  });

function Demo() {

  return (
    <MuiThemeProvider theme={theme1}>
      <div>
           <InputLabel style={{ margin :8 }}>Title</InputLabel>
           <Input id="title" />
      </div>
      <div>
        <MuiThemeProvider theme={theme2}>
            <InputLabel style={{ margin :8 }}>Title</InputLabel>
            <Input id="title" />
        </MuiThemeProvider>
      </div>
    </MuiThemeProvider>
  );
}

export default Demo;

screen shot 2017-12-09 at 10 04 43 pm

Your Environment

| Tech | Version |
|--------------|---------|
| Material-UI | v1.0.0 beta.23 |
| React | 16.0.0 |

question

Most helpful comment

Theme merging won't happen by magic. Right now, you are rewriting the whole overrides object in theme2.

>All comments

Theme merging won't happen by magic. Right now, you are rewriting the whole overrides object in theme2.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

finaiized picture finaiized  路  3Comments

reflog picture reflog  路  3Comments

mb-copart picture mb-copart  路  3Comments

TimoRuetten picture TimoRuetten  路  3Comments

activatedgeek picture activatedgeek  路  3Comments