Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add a Google Font to a VueJS Component?

I've been trying for an hour to find a way to import a Google Font into a VueJS Component, but I cannot seem to find a solution, nothing worked yet, not even the stuff from previous StackOverflow questions. All the answers I've found are 1.5 to 2 years old now. I would appreciate it greatly if someone could suggest an up to date solution.

I am using VueJS2 + Webpack + Vue-cli

like image 663
Holiday Avatar asked Jul 25 '18 10:07

Holiday


People also ask

How do I embed a Google font?

To add google fonts, search for the google fonts, select the font category and family, then select the font style of your choice. Once you select the font, “copy the font link”, from the “selected families windows” and paste it in the head section of the HTML file.


1 Answers

The fastest way is to import the font in a CSS file, for example App.css, if all components should have it:

@import url('https://fonts.googleapis.com/css?family=Roboto+Condensed');  html, body {   font-family: 'Roboto', sans-serif; }  #app {   font-family: 'Roboto', sans-serif; } 

The import statement is also shown by Google Fonts.

Select your fonts, click on Embed and then @import at the selection window:

Google Fonts

like image 161
Bennett Dams Avatar answered Oct 13 '22 17:10

Bennett Dams