overwriting font-family
There are many inline font-families and so it's not possible to overwrite them using sass variables.

Please only create issues with the provided issue creator. In the boilerplate for creating an issue, it explains that any ticket made without this will be automatically closed. For general questions, please join the Discord chat room. You can also check reddit or stackoverflow. Thank you.
@noorzaie Probably better to ask this in the discord channel. Anyway, here's how you change the font:
Add custom sass file as per the instructions in the docs: https://vuetifyjs.com/en/customization/sass-variables
Then add this in your sass file
@import "~vuetify/src/styles/styles.sass";
@import url("https://fonts.googleapis.com/css?family=Maven+Pro:400,500,700,900&display=swap");
$body-font-family: "Maven Pro" !important;
And replace the font with whatever font you want.
This just changes global font family. But the problem I've faced is inline styles. You can see inline font-family in image I've attached. So overwriting $body-font-family won't work in this case.
The value of $body-font-family is "Roboto", sans-serif !default and is different from inline styles, So I think inline font-families are not using from the sass variable.
https://github.com/vuetifyjs/vuetify/blob/master/packages/vuetify/src/styles/elements/_typography.sass#L42
Reopened this because I got the same issue, the font doesn't apply to headings (h1, h2...) tags... So when using typography with class like title (which is h6) the custom font doesn't get applied...
A comment in SO also stated it:
https://stackoverflow.com/questions/45598884/change-default-font-in-vuetify
I had to declare my custom font-family before importing the default vuetify style in my custom main.scss. That way vuetify properly picks up the custom definition:
$body-font-family: ...;
@import "~vuetify/src/styles/styles.sass";
Thank you for your reply!
Unfortunately it still doesn't work for me...
I did the way you described, and in my nuxt.config.js I have:
head: {
...
link: [
{
rel: 'stylesheet',
href: 'https://fonts.googleapis.com/css?family=Varela+Round'
}
]
},
/*
** Global CSS
*/
css: ['~/assets/scss/main.scss'],
...
modules: [
'@nuxtjs/style-resources',
],
styleResources: {
scss: ['~/assets/scss/variables.scss']
},
...
vuetify: {
customVariables: ['~/assets/scss/variables.scss'],
theme: {
...
}
}
},
And in my ~/assets/scss/main.scss file:
$body-font-family: 'Varela Round';
$heading-font-family: 'Varela Round'; // With or without this line, it still doesn't work
@import '~vuetify/src/styles/styles.sass';
None of the solutions work: I have nuxt.config with
buildModules: [
// https://github.com/nuxt-community/vuetify-module#readme
'@nuxtjs/vuetify'
...
]
...
vuetify: {
customVariables: ['~/assets/scss/vuetifyvariables.scss'],
theme: {
dark: false
}
....
and in my ~/assets/scss/vuetifyvariables.scss I wrote:
$body-font-family: 'FSAlbertWeb-Regular',Helvetica,sans-serif;
@import "~vuetify/src/styles/styles.sass";
Still I see:
.v-application {
font-family: "Roboto", sans-serif;
line-height: 1.5;
}
Has anyone solved this problem?
No.. They "solved" it by closing the issue without a solution. I had to overwrite it by css using important!
No.. They "solved" it by closing the issue without a solution. I had to overwrite it by css using important!
emmm... I think I will follow your steps.
I had to declare my custom font-family before importing the default vuetify style in my custom main.scss. That way vuetify properly picks up the custom definition:
$body-font-family: ...; @import "~vuetify/src/styles/styles.sass";
In case anyone else is reading this, this definitely worked for me.
I also cant change the font family. I have this:
@import './fontface.scss';
$body-font-family: 'GT-Walsheim-Regular', sans-serif;
$heading-font-family: 'GT-Walsheim-Regular', sans-serif;
@import '~vuetify/src/styles/settings/_variables';
@each $heading, $style in $headings {
$headings: map-merge($headings, ($heading: map-merge($style, ('font-family': $heading-font-family))));
}
Anyone can help?
Is there any working example of how to replace main fonts?
Worked for me!
nuxt.config.js
vuetify: {
customVariables: ['~/assets/variables.scss'],
theme: {
dark: false
}
},
variables.scss
$body-font-family: Montserrat;
.v-application {
.display-1,
.display-2,
.display-3,
.display-4,
.headline,
.title,
.subtitle-1,
.subtitle-2,
.body-1,
.body-2,
.caption,
.overline {
font-family: $body-font-family !important;
}
}
@filipyoo, @pimboden: Perhaps you are missing treeShake: true in nuxt.config.js file vuetify section?
I wrote a short article explaining the solution, there's also a complete code example at the end: https://medium.com/untitled-factory/changing-default-font-in-vuetify-js-and-nuxt-js-3894e726ff10
Re-open this, it's not fixed. It's literally impossible to override the default Roboto font.
Same here, trying everthing. Nothing work.
I find a workaround!
I tried to use custom variables, but the import import 'vuetify/dist/vuetify.min.css'; was overwriting my definitions.
So I appealed to css specificity, and setup my overwriting with css id, and it's beats the class overwrite from vuetify.min.css.
If anyone needs, just create this file on ./src/sass/variables.scss:
// @/sass/variables.scss
@import url('https://fonts.googleapis.com/css?family=Open+Sans:300,400,400i,600,700,800&display=swap');
$body-font-family: 'Open Sans';
$typoOptions: display-4, display-3, display-2, display-1, headline, title, subtitle-1, subtitle-2, body-1, body-2, caption, overline;
#app {
font-family: $body-font-family, sans-serif !important;
@each $typoOption in $typoOptions {
.#{$typoOption} {
font-family: $body-font-family, sans-serif !important;
}
}
}
P.S.:
- I know that I no need custom variables to do that, but since that is already loading by vuetify-loader, seems comfortable to use that way until another solution appears.
- I have installed vuetify using vue cli 3, so the vuetify-loader will automatically bootstrap the file, already said that, rsrs.
- typoOptions is the classes that you want to replace, and if you set in #app like me, this will replace everything too.
- #app is the id from div used to mount Vue
So i forced this by css, is not ideal but... it that I have for now. I Hope this help anyone else.
Salvation is easy peasy, do not use this crap. if you need something, take a look and reverse engineer it.