How to change the font in react: 1. Check the browser compatibility of the CSS3 "@font-face" attribute; 2. Place the font name you want to use in the assets directory; 3. In the "index .js", and then you can use the new font globally.
The operating environment of this tutorial: Windows 10 system, react18.0.0 version, Dell G3 computer.
How to change the font in react?
Use your own font in react
Today I encountered a requirement to use a specific font in the project because there are more words and it is convenient I will do effects later, so I adopted the @font-face rule of CSS3.
1. Let’s first look at compatibility: we found that most browsers already support
Most browsers already support
2. Next, take a look at its syntax: the most important thing is that font-family is used to specify a custom font name, src is used to specify the font path, and other attributes are optional
Syntax, font-family and src must be selected
3. The last way is to use it in react: first place the font name you want to use in the assets directory, and then call it in index.js Define font in index.css, and then you can use it globally
Put the font file in src
Introduce
into the outermost index.css Recommended learning: "react video tutorial"
The above is the detailed content of How to change the font in react. For more information, please follow other related articles on the PHP Chinese website!