26
How to add custom font file to your React App?
Before everything gets started, go ahead and run the following code in your terminal.
npx create-react-app [app-name]
cd [app-name]
code .
In this case, I will download Airbnb Cereal App font from this website: Airbnb Cereal App Font.
In this case, I will create
@font-face
in my App.css file. Open your App.css and write:
@font-face {
font-family: "Light"; /*Can be any text*/
src: local("AirbnbCerealLight"),
url("./font/AirbnbCerealLight.ttf") format("truetype");
}
Continue to write for the other font files in the same format.
Notice that if your font file is .woff format, you should write the format if woff like this:
@font-face {
font-family: "Medium"; /*Can be any text*/
src: local("AirbnbCerealMedium"),
url("./font/AirbnbCerealMedium.woff") format("woff");
}
Thanks for reading; I hope you are getting excited and finding this helpful.
See you in the next post.
26