-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,355
  • 1
  • 7
  • 17
Ben Johnson
  • 338
  • 1
  • 3
  • 11

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,927
  • 2
  • 17
  • 26
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
  • 655
  • 1
  • 7
  • 17