New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use a custom font? #3896
Comments
This comment has been minimized.
This comment has been minimized.
Actually, after 6 hours of searching online, digging in lib code and randomly guessing, the conclusion I arrived at: IT IS POSSIBLE! :D
@font-face {
font-family: 'inglobal';
font-weight: normal;
font-style: normal;
src: url('./inglobal.ttf');
}
4/b. If, for any reason, it still doesn't work, change the fonts' extensions to .css (also at Alternatively, https://material-ui.com/customization/typography/#self-hosted-fonts |
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,500,700&display=swap" rel="stylesheet">
/* Styles */
body {
margin: 0 auto;
font-family: 'Montserrat';
}
import { MuiThemeProvider, createMuiTheme } from '@material-ui/core/styles';
const theme = createMuiTheme({
typography: {
fontFamily: [
'Montserrat'
].join(','),
},
}) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Follow these 2 steps to change default font: Here I'm changing default font to "Open Sans"
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;700&display=swap" rel="stylesheet"/>
import { ThemeProvider } from '@material-ui/styles';
import { CssBaseline } from '@material-ui/core';
import { createMuiTheme } from '@material-ui/core';
const theme = createMuiTheme({ typography: { fontFamily: [ 'Open Sans' ].join(','), }, })
ReactDOM.render(
<ThemeProvider theme={theme}>
<CssBaseline />
<App />
</ThemeProvider>,
document.getElementById('root')
); |
Why are we forced to use fonts bundled with material-ui?
Is there a way to remove or configure this?
The text was updated successfully, but these errors were encountered: