How do I add a Google Font to a VueJS Component? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30 pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!How to add some non-standard font to a website?Can I embed a custom font in an iPhone application?How to add multiple font files for the same font?VueJS : using Ckeditor AND Google AnalyticsES6 import using at ('@') sign in path in a vue.js project using Webpackset watcher on props of vuejs componentHow to include js files on a vuejs component?How to include a CDN to VueJS CLI without NPM or Webpack?How do I use other vuejs component directly in my static HTML?Failed to decode downloaded font. OTS parsing error. VueJs
Married in secret, can marital status in passport be changed at a later date?
What *exactly* is electrical current, voltage, and resistance?
What helicopter has the most rotor blades?
Why did Israel vote against lifting the American embargo on Cuba?
When speaking, how do you change your mind mid-sentence?
Preserving file and folder permissions with rsync
What is /etc/mtab in Linux?
Is Bran literally the world's memory?
What is the numbering system used for the DSN dishes?
Determinant of a matrix with 2 equal rows
France's Public Holidays' Puzzle
Will I be more secure with my own router behind my ISP's router?
Test if all elements of a Foldable are the same
Suing a Police Officer Instead of the Police Department
Arriving in Atlanta (after US Preclearance in Dublin). Will I go through TSA security in Atlanta to transfer to a connecting flight?
All ASCII characters with a given bit count
Putting Ant-Man on house arrest
Protagonist's race is hidden - should I reveal it?
Has a Nobel Peace laureate ever been accused of war crimes?
Is it accepted to use working hours to read general interest books?
`FindRoot [ ]`::jsing: Encountered a singular Jacobian at a point...WHY
Why do people think Winterfell crypts is the safest place for women, children & old people?
Why would the Overseers waste their stock of slaves on the Game?
How did Elite on the NES work?
How do I add a Google Font to a VueJS Component?
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30 pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!How to add some non-standard font to a website?Can I embed a custom font in an iPhone application?How to add multiple font files for the same font?VueJS : using Ckeditor AND Google AnalyticsES6 import using at ('@') sign in path in a vue.js project using Webpackset watcher on props of vuejs componentHow to include js files on a vuejs component?How to include a CDN to VueJS CLI without NPM or Webpack?How do I use other vuejs component directly in my static HTML?Failed to decode downloaded font. OTS parsing error. VueJs
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
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
vue.js fonts vuejs2
add a comment |
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
vue.js fonts vuejs2
You should say what you've tried so far
– André
Jul 25 '18 at 10:15
I cannot backtrace of what I've tried. I have tried solutions from every blog, stackoverflow, quora question, vuejs that had that topic, but all of them were for VueJS and not VueJS2. Cannot find anything on VueJS2.I'm sure any up to date solution would work
– Holiday
Jul 25 '18 at 10:53
@André Turns out it was an impossible to see bug all the time that shouldn't be one. Two hours on a bug as usual. Thanks for taking your time to reply Andre.
– Holiday
Jul 25 '18 at 10:56
1
The default@import
way described in Google Fonts works fine (check App.vue): codesandbox.io/s/5yyp394zon | Also the<link>
way (check index.html): codesandbox.io/s/40v3z6vy3x
– yuriy636
Jul 25 '18 at 11:30
add a comment |
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
vue.js fonts vuejs2
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
vue.js fonts vuejs2
vue.js fonts vuejs2
edited Jul 25 '18 at 12:15
Bennett Dams
1,5921419
1,5921419
asked Jul 25 '18 at 10:00
HolidayHoliday
3817
3817
You should say what you've tried so far
– André
Jul 25 '18 at 10:15
I cannot backtrace of what I've tried. I have tried solutions from every blog, stackoverflow, quora question, vuejs that had that topic, but all of them were for VueJS and not VueJS2. Cannot find anything on VueJS2.I'm sure any up to date solution would work
– Holiday
Jul 25 '18 at 10:53
@André Turns out it was an impossible to see bug all the time that shouldn't be one. Two hours on a bug as usual. Thanks for taking your time to reply Andre.
– Holiday
Jul 25 '18 at 10:56
1
The default@import
way described in Google Fonts works fine (check App.vue): codesandbox.io/s/5yyp394zon | Also the<link>
way (check index.html): codesandbox.io/s/40v3z6vy3x
– yuriy636
Jul 25 '18 at 11:30
add a comment |
You should say what you've tried so far
– André
Jul 25 '18 at 10:15
I cannot backtrace of what I've tried. I have tried solutions from every blog, stackoverflow, quora question, vuejs that had that topic, but all of them were for VueJS and not VueJS2. Cannot find anything on VueJS2.I'm sure any up to date solution would work
– Holiday
Jul 25 '18 at 10:53
@André Turns out it was an impossible to see bug all the time that shouldn't be one. Two hours on a bug as usual. Thanks for taking your time to reply Andre.
– Holiday
Jul 25 '18 at 10:56
1
The default@import
way described in Google Fonts works fine (check App.vue): codesandbox.io/s/5yyp394zon | Also the<link>
way (check index.html): codesandbox.io/s/40v3z6vy3x
– yuriy636
Jul 25 '18 at 11:30
You should say what you've tried so far
– André
Jul 25 '18 at 10:15
You should say what you've tried so far
– André
Jul 25 '18 at 10:15
I cannot backtrace of what I've tried. I have tried solutions from every blog, stackoverflow, quora question, vuejs that had that topic, but all of them were for VueJS and not VueJS2. Cannot find anything on VueJS2.I'm sure any up to date solution would work
– Holiday
Jul 25 '18 at 10:53
I cannot backtrace of what I've tried. I have tried solutions from every blog, stackoverflow, quora question, vuejs that had that topic, but all of them were for VueJS and not VueJS2. Cannot find anything on VueJS2.I'm sure any up to date solution would work
– Holiday
Jul 25 '18 at 10:53
@André Turns out it was an impossible to see bug all the time that shouldn't be one. Two hours on a bug as usual. Thanks for taking your time to reply Andre.
– Holiday
Jul 25 '18 at 10:56
@André Turns out it was an impossible to see bug all the time that shouldn't be one. Two hours on a bug as usual. Thanks for taking your time to reply Andre.
– Holiday
Jul 25 '18 at 10:56
1
1
The default
@import
way described in Google Fonts works fine (check App.vue): codesandbox.io/s/5yyp394zon | Also the <link>
way (check index.html): codesandbox.io/s/40v3z6vy3x– yuriy636
Jul 25 '18 at 11:30
The default
@import
way described in Google Fonts works fine (check App.vue): codesandbox.io/s/5yyp394zon | Also the <link>
way (check index.html): codesandbox.io/s/40v3z6vy3x– yuriy636
Jul 25 '18 at 11:30
add a comment |
4 Answers
4
active
oldest
votes
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 Condensed', sans-serif;
#app
font-family: 'Roboto Condensed', sans-serif;
The import statement is also shown by Google Fonts (click on @IMPORT
in the selection window):
add a comment |
Imo, if you're using VueJS, Google Fonts Webpack Plugin is the way.
Here's the plugin, it's really easy to set it up and works like a charm.
npm i google-fonts-webpack-plugin -D
Go to your /webpack.config.js
/ webpack.base.config.js
and add the following lines:
const GoogleFontsPlugin = require("google-fonts-webpack-plugin")
module.exports =
"entry": "index.js",
/* ... */
plugins: [
new GoogleFontsPlugin(
fonts: [
family: "Source Sans Pro" ,
family: "Roboto", variants: [ "400", "700italic" ]
]
)
]
Now you can use Google Fonts anywhere inside your VueJS project :)
add a comment |
I would like to add to the answer given by msqar. If you are going to use Google Fonts Webpack Plugin: (https://www.npmjs.com/package/google-fonts-webpack-plugin )
and you are using the Vue CLI, you can add a vue.config.js file inside the root of your project. See Vue CLI docs: (https://cli.vuejs.org/guide/webpack.html#simple-configuration)
Then add the code to that file:
const GoogleFontsPlugin = require("google-fonts-webpack-plugin");
module.exports =
chainWebpack: config =>
plugins: [
new GoogleFontsPlugin(
fonts: [
family: "Source Sans Pro"
]
)
]
add a comment |
In Vue2, just @import the font in section inside your vue component
<style>
@import url('https://fonts.googleapis.com/css?family=Proza+Libre');
h1
font-family: 'Proza Libre', sans-serif;
color: seagreen;
font-weight: 300;
</style>
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51516084%2fhow-do-i-add-a-google-font-to-a-vuejs-component%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 Condensed', sans-serif;
#app
font-family: 'Roboto Condensed', sans-serif;
The import statement is also shown by Google Fonts (click on @IMPORT
in the selection window):
add a comment |
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 Condensed', sans-serif;
#app
font-family: 'Roboto Condensed', sans-serif;
The import statement is also shown by Google Fonts (click on @IMPORT
in the selection window):
add a comment |
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 Condensed', sans-serif;
#app
font-family: 'Roboto Condensed', sans-serif;
The import statement is also shown by Google Fonts (click on @IMPORT
in the selection window):
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 Condensed', sans-serif;
#app
font-family: 'Roboto Condensed', sans-serif;
The import statement is also shown by Google Fonts (click on @IMPORT
in the selection window):
edited Mar 9 at 4:02
Community♦
11
11
answered Jul 25 '18 at 11:29
Bennett DamsBennett Dams
1,5921419
1,5921419
add a comment |
add a comment |
Imo, if you're using VueJS, Google Fonts Webpack Plugin is the way.
Here's the plugin, it's really easy to set it up and works like a charm.
npm i google-fonts-webpack-plugin -D
Go to your /webpack.config.js
/ webpack.base.config.js
and add the following lines:
const GoogleFontsPlugin = require("google-fonts-webpack-plugin")
module.exports =
"entry": "index.js",
/* ... */
plugins: [
new GoogleFontsPlugin(
fonts: [
family: "Source Sans Pro" ,
family: "Roboto", variants: [ "400", "700italic" ]
]
)
]
Now you can use Google Fonts anywhere inside your VueJS project :)
add a comment |
Imo, if you're using VueJS, Google Fonts Webpack Plugin is the way.
Here's the plugin, it's really easy to set it up and works like a charm.
npm i google-fonts-webpack-plugin -D
Go to your /webpack.config.js
/ webpack.base.config.js
and add the following lines:
const GoogleFontsPlugin = require("google-fonts-webpack-plugin")
module.exports =
"entry": "index.js",
/* ... */
plugins: [
new GoogleFontsPlugin(
fonts: [
family: "Source Sans Pro" ,
family: "Roboto", variants: [ "400", "700italic" ]
]
)
]
Now you can use Google Fonts anywhere inside your VueJS project :)
add a comment |
Imo, if you're using VueJS, Google Fonts Webpack Plugin is the way.
Here's the plugin, it's really easy to set it up and works like a charm.
npm i google-fonts-webpack-plugin -D
Go to your /webpack.config.js
/ webpack.base.config.js
and add the following lines:
const GoogleFontsPlugin = require("google-fonts-webpack-plugin")
module.exports =
"entry": "index.js",
/* ... */
plugins: [
new GoogleFontsPlugin(
fonts: [
family: "Source Sans Pro" ,
family: "Roboto", variants: [ "400", "700italic" ]
]
)
]
Now you can use Google Fonts anywhere inside your VueJS project :)
Imo, if you're using VueJS, Google Fonts Webpack Plugin is the way.
Here's the plugin, it's really easy to set it up and works like a charm.
npm i google-fonts-webpack-plugin -D
Go to your /webpack.config.js
/ webpack.base.config.js
and add the following lines:
const GoogleFontsPlugin = require("google-fonts-webpack-plugin")
module.exports =
"entry": "index.js",
/* ... */
plugins: [
new GoogleFontsPlugin(
fonts: [
family: "Source Sans Pro" ,
family: "Roboto", variants: [ "400", "700italic" ]
]
)
]
Now you can use Google Fonts anywhere inside your VueJS project :)
answered Dec 18 '18 at 14:54
msqarmsqar
79321948
79321948
add a comment |
add a comment |
I would like to add to the answer given by msqar. If you are going to use Google Fonts Webpack Plugin: (https://www.npmjs.com/package/google-fonts-webpack-plugin )
and you are using the Vue CLI, you can add a vue.config.js file inside the root of your project. See Vue CLI docs: (https://cli.vuejs.org/guide/webpack.html#simple-configuration)
Then add the code to that file:
const GoogleFontsPlugin = require("google-fonts-webpack-plugin");
module.exports =
chainWebpack: config =>
plugins: [
new GoogleFontsPlugin(
fonts: [
family: "Source Sans Pro"
]
)
]
add a comment |
I would like to add to the answer given by msqar. If you are going to use Google Fonts Webpack Plugin: (https://www.npmjs.com/package/google-fonts-webpack-plugin )
and you are using the Vue CLI, you can add a vue.config.js file inside the root of your project. See Vue CLI docs: (https://cli.vuejs.org/guide/webpack.html#simple-configuration)
Then add the code to that file:
const GoogleFontsPlugin = require("google-fonts-webpack-plugin");
module.exports =
chainWebpack: config =>
plugins: [
new GoogleFontsPlugin(
fonts: [
family: "Source Sans Pro"
]
)
]
add a comment |
I would like to add to the answer given by msqar. If you are going to use Google Fonts Webpack Plugin: (https://www.npmjs.com/package/google-fonts-webpack-plugin )
and you are using the Vue CLI, you can add a vue.config.js file inside the root of your project. See Vue CLI docs: (https://cli.vuejs.org/guide/webpack.html#simple-configuration)
Then add the code to that file:
const GoogleFontsPlugin = require("google-fonts-webpack-plugin");
module.exports =
chainWebpack: config =>
plugins: [
new GoogleFontsPlugin(
fonts: [
family: "Source Sans Pro"
]
)
]
I would like to add to the answer given by msqar. If you are going to use Google Fonts Webpack Plugin: (https://www.npmjs.com/package/google-fonts-webpack-plugin )
and you are using the Vue CLI, you can add a vue.config.js file inside the root of your project. See Vue CLI docs: (https://cli.vuejs.org/guide/webpack.html#simple-configuration)
Then add the code to that file:
const GoogleFontsPlugin = require("google-fonts-webpack-plugin");
module.exports =
chainWebpack: config =>
plugins: [
new GoogleFontsPlugin(
fonts: [
family: "Source Sans Pro"
]
)
]
edited Dec 26 '18 at 1:23
answered Dec 22 '18 at 21:49
Michael HicksMichael Hicks
42111
42111
add a comment |
add a comment |
In Vue2, just @import the font in section inside your vue component
<style>
@import url('https://fonts.googleapis.com/css?family=Proza+Libre');
h1
font-family: 'Proza Libre', sans-serif;
color: seagreen;
font-weight: 300;
</style>
add a comment |
In Vue2, just @import the font in section inside your vue component
<style>
@import url('https://fonts.googleapis.com/css?family=Proza+Libre');
h1
font-family: 'Proza Libre', sans-serif;
color: seagreen;
font-weight: 300;
</style>
add a comment |
In Vue2, just @import the font in section inside your vue component
<style>
@import url('https://fonts.googleapis.com/css?family=Proza+Libre');
h1
font-family: 'Proza Libre', sans-serif;
color: seagreen;
font-weight: 300;
</style>
In Vue2, just @import the font in section inside your vue component
<style>
@import url('https://fonts.googleapis.com/css?family=Proza+Libre');
h1
font-family: 'Proza Libre', sans-serif;
color: seagreen;
font-weight: 300;
</style>
answered Apr 18 at 14:07
Elisabeth ShevtsovaElisabeth Shevtsova
37638
37638
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f51516084%2fhow-do-i-add-a-google-font-to-a-vuejs-component%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You should say what you've tried so far
– André
Jul 25 '18 at 10:15
I cannot backtrace of what I've tried. I have tried solutions from every blog, stackoverflow, quora question, vuejs that had that topic, but all of them were for VueJS and not VueJS2. Cannot find anything on VueJS2.I'm sure any up to date solution would work
– Holiday
Jul 25 '18 at 10:53
@André Turns out it was an impossible to see bug all the time that shouldn't be one. Two hours on a bug as usual. Thanks for taking your time to reply Andre.
– Holiday
Jul 25 '18 at 10:56
1
The default
@import
way described in Google Fonts works fine (check App.vue): codesandbox.io/s/5yyp394zon | Also the<link>
way (check index.html): codesandbox.io/s/40v3z6vy3x– yuriy636
Jul 25 '18 at 11:30