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
No change in color occurs or fontFamily
https://codesandbox.io/s/8444zvr28j
const theme = createMuiTheme({
overrides: {
MuiTypography: {
root: {
fontFamily: "Product Sans"
},
colorPrimary: purple
}
}
});
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
| Tech | Version . |
|--------------|------------------|
| Material-UI | 1.0.0-beta.36 |
| React | 16.2.0 |
| browser | Chrome 64 . |
It's not supposed to work this way. Have a look at this documentation section for changing the default font: https://material-ui-next.com/customization/themes/#Typography. Regarding the color, you need to provide some CSS, you can't provide a color object directly.
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
@naji247 You can do it like this in your example:
const theme = createMuiTheme({
typography: {
fontFamily: "Product Sans",
},
overrides: {
MuiTypography: {
body1: {
color: purple[500],
},
subheading: {
color: purple[500],
},
}
}
});
Your changes didn't change the fontFamily application wide though...?
On Wed, Mar 7, 2018 at 12:46 PM, Olivier Tassinari <[email protected]
wrote:
Closed #10552 https://github.com/mui-org/material-ui/issues/10552.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/mui-org/material-ui/issues/10552#event-1509808200,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AB1N45qC2Lpln66JKpFIrz5CawOgAR18ks5tcEdDgaJpZM4Sf19z
.
It's still all Roboto
On Wed, Mar 7, 2018 at 12:58 PM, Naseem Al-Naji naji247@gmail.com wrote:
Your changes didn't change the fontFamily application wide though...?
On Wed, Mar 7, 2018 at 12:46 PM, Olivier Tassinari <
[email protected]> wrote:Closed #10552 https://github.com/mui-org/material-ui/issues/10552.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/mui-org/material-ui/issues/10552#event-1509808200,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AB1N45qC2Lpln66JKpFIrz5CawOgAR18ks5tcEdDgaJpZM4Sf19z
.
Your changes didn't change the fontFamily application wide
@naji247 I have updated the code. Now, it does. It would have been simpler if you had a closer look at the documentation.
I'm having a similar issue modifying the value of marginBottom, I can accomplish a change in spacing that is applied to all typography components (from the answer on this stackoverflow question) but I would like to vary the gutter depending on what variant is used.
My code looks like this currently:
const baseTheme = createMuiTheme({
spacing: factor => `${0.5 * factor}rem`,
});
const theme = createMuiTheme({
...baseTheme,
overrides: {
MuiTypography: {
gutterBottom: {
marginBottom: baseTheme.spacing(5),
},
},
}
})
export default responsiveFontSizes(theme)
What I would like to do:
const baseTheme = createMuiTheme({
spacing: factor => `${0.5 * factor}rem`,
});
const theme = createMuiTheme({
...baseTheme,
overrides: {
MuiTypography: {
h1: {
gutterBottom: {
marginBottom: baseTheme.spacing(5),
},
},
},
}
})
export default responsiveFontSizes(theme)
Is this possible?
@mrmadhat Yes, you can use a global CSS selector .MuiTypography-gutterBottom or a style function.
@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?
@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.
Great, thankyou!
I had a similar issue, fontFamily was working in the first level of nested components and finally, I fixed it by using !important
const theme = createMuiTheme({
typography: {
fontFamily: "'YekanBakh !important'",
},
});
ReactDOM.render(
<ThemeProvider theme={theme}>
<RTL>
<SnackbarProvider>
<App />
</SnackbarProvider>
</RTL>
</ThemeProvider>
, document.getElementById('root'));
I tested all the solution you suggested but none of them worked.
__any idea?__
I had a similar issue,
fontFamilywas working in the first level of nested components and finally, I fixed it by using!importantconst theme = createMuiTheme({ typography: { fontFamily: "'YekanBakh !important'", }, }); ReactDOM.render( <ThemeProvider theme={theme}> <RTL> <SnackbarProvider> <App /> </SnackbarProvider> </RTL> </ThemeProvider> , document.getElementById('root'));I tested all the solution you suggested but none of them worked.
any idea?
I found what makes the problem. I used google-maps-react. I used the Typography component in InfoWindow to show some details on each marker. changing Typography to normal HTML h6 solved the issue.
__has issue__
<Typography variant="h6" className={classes.activePlaceCardTitle}>{activePlace.name}</Typography>
__correct__
<h6 className={classes.activePlaceCardTitle}>{activePlace.name}</h6>
__Reason__ : Typography overrides default style on my customized style