How to Add Custom Fonts in VueJS ?
Last Updated :
28 Apr, 2025
Vue.js is a JavaScript framework used in building powerful and beautiful user interfaces. The key feature of Vue.js is its component-based architecture that allows the developers to create reusable and modular components.
Custom fonts can bring uniqueness and visual appeal to your Vue.js applications, enhancing the overall user experience. In this article, we’ll learn how to add custom fonts in Vuejs.
Step for Creating VueJS Application and adding Custom Fonts
Step 1: Install Vue modules using the below npm command
npm install vue
Step 2: Use Vue JS through CLI. Open your terminal or command prompt and run the below command.
npm install --global vue-cli
Step 3: Create the new project using the below command
vue init webpack vueproject
Step 4: Change the directory to the newly created project
cd vueproject
Step 5: Add the custom fonts (like Google Fonts) in public/index.html
To use custom fonts in Vuejs, we are going to add Google fonts for now. The <link> tag consists of the font data, so we are going to add that inside the <head> tag in the index.html file.
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Rubik:wght@500&display=swap" rel="stylesheet">
Step 6: Using fonts in Vue Js components
.custom-font {
font-family: 'Rubik', sans-serif;
}
Project Structure
The following project structure will be generated after completing the above-required steps:

Example 1: Below example demonstrates the use of custom fonts in Vue.js elements.
HTML
<template>
<div id="app">
<h1 class="gfg">GeeksforGeeks</h1>
<h2>How to add custom fonts in Vue JS</h2>
<div>
<p class="rubik">
Welcome to GeeksforGeeks! A
computer science portal.
</p>
</div>
</div>
</template>
<style>
.gfg {
color: green;
font-size: 30px;
}
.rubik {
font-family: "Rubik", sans-serif;
}
</style>
JavaScript
import { createApp } from 'vue'
import App from './App.vue'
import './index.css'
createApp(App).mount('#app')
Output:

Example 2: Below example demonstrates the use of google fonts in Vue.js input elements.
JavaScript
<template>
<div id="app">
<h1 class="gfg">GeeksforGeeks</h1>
<h2>How to add custom fonts in Vue JS</h2>
<p id="bebas">
This text is written using the custom google fonts
</p>
</div>
</template>
<style>
@import url(
'https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap');
.gfg {
color: green;
font-size: 30px;
}
#bebas {
font-family: 'Bebas Neue', sans-serif;
}
</style>
JavaScript
import { createApp } from 'vue'
import App from './App.vue'
import './index.css'
createApp(App).mount('#app')
Output:

Similar Reads
How to replace all occurrences of a string using Vue.js filters ? In this article, we are going to learn how to replace all occurrences of a particular word with some other word using filters in VueJS. Vue is a progressive framework for building user interfaces. Filters are a functionality provided by Vue components that let you apply formatting and transformation
2 min read
How to set a click event once a page or view is loaded in vue.js? In this article, we will discuss how to set a click event once a page or view is loaded in vue.js. Just like every other JavaScript framework Vue also supports the Mounting hooks. Mounting hooks are often the most used hooks. They allow us to access or modify the DOM of your component just before or
2 min read
How to check an image is loaded or not in VueJS ? While inserting an Image in a VueJS project, it may fail to load due to the following reasons: Writing wrong image URL.Due to poor connection Approach: We are going to use an event in <img> to check whether an image is loaded or not in VueJS, the event we are going to use is: @load: The @load
3 min read
How to loop through a list of elements and display it in VueJS ? Vue is a progressive framework for building user interfaces. The core library is focused on the view layer only and is easy to pick up and integrate with other libraries. Vue is also perfectly capable of powering sophisticated Single-Page Applications in combination with modern tooling and supportin
2 min read
How to Make localStorage Reactive in Vue.js ? In Vue, localStorage is used to store data locally in the browser. However, by default, changes made to localStorage are not reactive in Vue. This means that if the localStorage is updated outside of the Vue component, the component will not be aware of the changes and will not update accordingly. T
3 min read
How to implement DateTime localization in vue.js ? In this article, we will see the implementation of Date Time localization in Vue.js, along with knowing its basic implementation through the illustration.Date() Object: In Javascript, the Date object works with dates and times. Date objects are created by the new Date() constructor.Syntax:const date
8 min read
Select different values on two select tags in Vue.js In this article, we will see the selection of different values on a single select and two <select> tags in vue.js, along with understanding their basic implementation through the examples.HTML <select> tag is used to create a drop-down list. Adding a list of options inside the drop-down
6 min read
How to convert a normal string to a uppercase string using filter in VueJS ? Filters are a functionality provided by Vue components that let you apply formatting and transformations to any part of your template dynamic data. The filter property of the component is an object. A single filter is a function that accepts a value and returns another value. The returned value is t
2 min read
How to dynamically add or remove items from a list in Vue.js ? Vue is a progressive framework for building user interfaces. The core library is focused on the view layer only and is easy to pick up and integrate with other libraries. Vue is also perfectly capable of powering sophisticated Single-Page Applications in combination with modern tooling and supportin
1 min read
How to binding inline styles in Vue.js ? Vue.js is an open-source ModelâViewâViewModel front-end JavaScript framework for building user interfaces and single-page applications. Every Web application needs HTML CSS styles for presenting a better User Interface. Vue.js allows you to dynamically render styling with data model structure. Usual
4 min read