-1

I am running in to trouble trying to add Google Fonts in to my React Application, Does anyone know the easiest way to do this?

AMolina
  • 1,335
  • 1
  • 6
  • 17
Ben Johnson
  • 188
  • 1
  • 2
  • 10

2 Answers2

3

You can import it like this

<style>
    @import url('https://fonts.googleapis.com/css?family=Roboto&display=swap');
</style>

Within the <head> tag in your index.html file

Hope this helps.

Shmili Breuer
  • 3,684
  • 1
  • 18
  • 23
0

If you want to make it available across your whole application, you can simply include a stylesheet tag in your index.html

Google fonts screenshot

<link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet">

Then you can simply style your component

const Komponent = () => (
  <h1 style={{ fontFamily: 'Roboto' }}> Styled Text </h1>
);
Cody Elhard
  • 567
  • 1
  • 5
  • 16