How to add fonts to create-react-app based projects?

前端 未结 7 1783
长情又很酷
长情又很酷 2020-11-29 15:19

I\'m using create-react-app and prefer not to eject.

It\'s not clear where fonts imported via @font-face and loaded locally should go.

Namely,

7条回答
  •  难免孤独
    2020-11-29 15:58

    1. Go to Google Fonts https://fonts.google.com/
    2. Select your font as depicted in image below:

    1. Copy and then paste that url in new tab you will get the css code to add that font. In this case if you go to

    https://fonts.googleapis.com/css?family=Spicy+Rice

    It will open like this:

    4, Copy and paste that code in your style.css and simply start using that font like this:

          
              React Rock
            
    

    Result:

提交回复
热议问题