How to use Google fonts in React.js?

前端 未结 12 807
既然无缘
既然无缘 2020-12-02 18:06

I had built a website with React.js and webpack.

I want to use Google fonts in the webpage, so I put the link in the section.

Go

12条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-02 18:29

    If you are using Create React App environment simply add @import rule to index.css as such:

    @import url('https://fonts.googleapis.com/css?family=Anton');
    

    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;
    

提交回复
热议问题