question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't Override Global Typography

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

I should be able to modify the typography through the overrides and see purple text with a different fontfamily for all text in my application

Current Behavior

No change in color occurs or fontFamily

Steps to Reproduce (for bugs)

https://codesandbox.io/s/8444zvr28j

  1. Use createMuiTheme with object:
const theme = createMuiTheme({
  overrides: {
    MuiTypography: {
      root: {
        fontFamily: "Product Sans"
      },
      colorPrimary: purple
    }
  }
});

Context

I’m working on a side project using MuiTable, and all the fonts are defaulted to Roboto 😦

I am using react-starter-kit and have imported fonts using webpack

Your Environment

Tech Version .
Material-UI 1.0.0-beta.36
React 16.2.0
browser Chrome 64 .

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
oliviertassinaricommented, Sep 15, 2019

@mrmadhat Both approaches should work:

const theme = createMuiTheme({
  overrides: {
    MuiTypography: {
      h1: {
        '&.MuiTypography-gutterBottom': {
          marginBottom: 7,
        },
      },
      h2: {
        marginBottom: props => (props.gutterBottom ? 20 : null),
      },
    },
  },
});

But notice that the “h2” approach is significantly slower, at least, until we solve a core issue with the styling solution.

1reaction
mrmadhatcommented, Sep 15, 2019

@oliviertassinari thankyou for your help, what I have now is:

export const GlobalCss = withStyles({
	'@global': {
		'.MuiTypography-h1.MuiTypography-gutterBottom': {
			marginBottom: baseTheme.spacing(5)
		},
		'.MuiTypography-h2.MuiTypography-gutterBottom': {
			marginBottom: baseTheme.spacing(3)
		}
	}
})(() => null);

Which works as expected, is there a better way to accomplish this? Could you possibly provide an example?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't Override Global Typography · Issue #10552 - GitHub
I'm working on a side project using MuiTable, and all the fonts are defaulted to Roboto :( I am using react-starter-kit and have...
Read more >
Overwrite Material UI 5.0 typography theme globally with ...
I'd like to apply them globally by overwriting the theme . My first issue is that I can't get the fonts to even...
Read more >
Typography doesn't work (global settings are overriding it)
I need help regarding the customizer (site settings). The global typography setting is overriding the regular typography setting.
Read more >
Typography - Material UI - MUI
Typography. The theme provides a set of type sizes that work well together, and also with the layout grid. Font family. You can...
Read more >
Typography | Webflow University
It's common to use this technique to set global font styles on the body tag, to align text and other elements inside of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found