in some cases your font resource maybe somewhere in your project directory. so you can load it like this using scss

 $list: (
    @mixin setrobotofonts {
      @each $var in $list {
        @font-face {
          font-family: "roboto-#{$var}";
          src: url("../fonts/roboto-#{$var}.ttf") format("ttf");
@include setrobotofonts();


it could be the self-closing tag of link at the end, try:

<link href="" rel="stylesheet"/> 

and in your main.css file try:

body,div {
  font-family: 'bungee inline', cursive;


edit index.css

@import url(",wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");

body {
  margin: 0;
  font-family: "poppins", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;


add link tag in index.html on root directory inside public folder.

<link href="" rel="stylesheet"/>

then use it in any css file.


i can see there are various different ways to include google fonts in react app. let's explore the most preferred and optimum way.

@import vs link

the two options that google font provides are using link and @import. so now the question directs toward decision in between @import and link. there is already a stack overflow question regarding this comparison and here is a reference from the accepted answer

<link> is preferred in all cases over @import, because the latter blocks parallel downloads, meaning that the browser will wait for the imported file to finish downloading before it starts downloading the rest of the content.

so, it's most preferable to use the link tag that google font provides

how to use link and why in a react app?

i have seen few answers giving this method as a solution but i want to make it more clear why it is most preferable.

after using create-react-app to initialize the project, you can see a comment in the index.html file inside the public folder as below.

you can add webfonts, meta tags, or analytics to this file. the build step will place the bundled scripts into the tag.

so you can simply include the link tag that google font provides in the head section of the above file.

<link href="" rel="stylesheet">

then you can use it in the css file and import in jsx

font-family: 'bungee inline', cursive;


i added the @import and the @font-face in my css file and it worked.enter image description here


if anyone looking for a solution with (.less) try below. open your main or common less file and use like below.

@import (css) url(',700');

  font-family: "open sans", sans-serif;


in case someone needs it, you can use @fontsource. they have all of the google fonts and seems easier than most of the solutions here.


another option to all of the good answers here is the npm package react-google-font-loader, found here.

the usage is simple:

import googlefontloader from 'react-google-font-loader';

// somewhere in your react tree:

            font: 'bungee inline',
            weights: [400],

then you can just use the family name in your css:

body {
    font-family: 'bungee inline', cursive;

disclaimer: i'm the author of the react-google-font-loader package.


had the same issue. turns out i was using " instead of '.

use @import url('within single quotes'); like this

not @import url("within double quotes"); like this


here are two different ways you can adds fonts to your react app.

adding local fonts

  1. create a new folder called fonts in your src folder.

  2. download the google fonts locally and place them inside the fonts folder.

  3. open your index.css file and include the font by referencing the path.

@font-face {
  font-family: 'rajdhani';
  src: local('rajdhani'), url(./fonts/rajdhani/rajdhani-regular.ttf) format('truetype');

here i added a rajdhani font.

now, we can use our font in css classes like this.

    font-family: rajdhani, serif;
    color: #0004;

adding google fonts

if you like to use google fonts (api) instead of local fonts, you can add it like this.

@import url(';500&display=swap');

similarly, you can also add it inside the index.html file using link tag.

<link href=";500&display=swap" rel="stylesheet">

(originally posted at


in your css file, such as app.css in a create-react-app, add a fontface import. for example:

@fontface {
  font-family: 'bungee inline', cursive;
  src: url('')

then simply add the font to the dom element within the same css file.

body {
  font-family: 'bungee inline', cursive;


you should see this tutorial:

import webfont from 'webfontloader';

  google: {
    families: ['titillium web:300,400,700', 'sans-serif']

i just tried this method and i can say that it works very well ;)


if you are using create react app environment simply add @import rule to index.css as such:

@import url('');

import index.css in your main react app:

import './index.css'

react gives you a choice of inline styling, css modules or styled components in order to apply css:

font-family: 'anton', sans-serif;


google fonts in react.js?

open your stylesheet i.e, app.css, style.css (what name you have), it doesn't matter, just open stylesheet and paste this code

@import url('');

and don't forget to change url of your font that you want, else working fine

and use this as :

body {
  font-family: 'josefin sans', cursive;


in some sort of main or first loading css file, just do:

@import url(',bold,italic&subset=latin,latin-ext');

you don't need to wrap in any sort of @font-face, etc. the response you get back from google's api is ready to go and lets you use font families like normal.

then in your main react app javascript, at the top put something like:

import './assets/css/fonts.css';

what i did actually was made an app.css that imported a fonts.css with a few font imports. simply for organization (now i know where all my fonts are). the important thing to remember is that you import the fonts first.

keep in mind that any component you import to your react app should be imported after the style import. especially if those components also import their own styles. this way you can be sure of the ordering of styles. this is why it's best to import fonts at the top of your main file (don't forget to check your final bundled css file to double check if you're having trouble).

there's a few options you can pass the google font api to be more efficient when loading fonts, etc. see official documentation: get started with the google fonts api

edit, note: if you are dealing with an "offline" application, then you may indeed need to download the fonts and load through webpack.

Related Query

More Query from same tag