Material-ui: Is using overrides in createMuiTheme valid in version 4?

Created on 8 Jan 2020  路  1Comment  路  Source: mui-org/material-ui

I am new to Material UI and have taken deep dive because we are using it at work.

I found that the following works when added to createMuiTheme:

    overrides: {
        MuiListItem: {
            root: {
                '&$selected': { color: '#fff' }
            }
        }
    }

I don't see anything about this in the docs for version 4. Is this valid for the long run, or is there a chance it will be depricated?

If this is a good way to make custom global styles, are there docs that have more resources in on how to do this?

Is there a better way to create custom global styles with supporting documentation?

question

Most helpful comment

@adamhinckley It's documented in https://material-ui.com/customization/globals/#css. We have no plan to remove this feature.

I have personally used it a few minutes ago, in this example I would rather customize the Container globally than create a wrapping component:

theme.overrides = {
  MuiContainer: {
    root: {
      paddingLeft: theme.spacing(1),
      paddingRight: theme.spacing(1),
      [theme.breakpoints.up('sm')]: {
        paddingLeft: theme.spacing(2),
        paddingRight: theme.spacing(2),
      },
      [theme.breakpoints.up('md')]: null,
    },
  },
};

>All comments

@adamhinckley It's documented in https://material-ui.com/customization/globals/#css. We have no plan to remove this feature.

I have personally used it a few minutes ago, in this example I would rather customize the Container globally than create a wrapping component:

theme.overrides = {
  MuiContainer: {
    root: {
      paddingLeft: theme.spacing(1),
      paddingRight: theme.spacing(1),
      [theme.breakpoints.up('sm')]: {
        paddingLeft: theme.spacing(2),
        paddingRight: theme.spacing(2),
      },
      [theme.breakpoints.up('md')]: null,
    },
  },
};
Was this page helpful?
0 / 5 - 0 ratings

Related issues

activatedgeek picture activatedgeek  路  3Comments

anthony-dandrea picture anthony-dandrea  路  3Comments

chris-hinds picture chris-hinds  路  3Comments

finaiized picture finaiized  路  3Comments

reflog picture reflog  路  3Comments