Answers for "how to add custom font to react project"

3

how to add custom font to react project

@font-face {
  font-family: "AssistantRegular";
  src: local("AssistantRegular"),
    url("./fonts/assistant.regular.ttf") format("truetype");
  font-weight: normal;
}
Posted by: Guest on January-10-2021
1

add font to react js

Create a folder called fonts under src
Download the required fonts into the src\fonts folder

Next, import the fonts into the index.js file.
import './fonts/Goldman/Goldman-Bold.ttf';

In the index.css file add,
@font-face {
font-family: "GoldmanBold";
src: local("GoldmanBold"),
 url("./fonts/Goldman/Goldman-Bold.ttf") format("truetype");
font-weight: bold;
}

Now add a class name in the App.css file that uses this family name.
.font-face-gm {
 font-family: "GoldmanBold";
}

Use this class name in your React component,
   <div className="font-face-gm">
              This is using Font Face. 
    </div>
Posted by: Guest on August-12-2021

Code answers related to "how to add custom font to react project"

Code answers related to "Javascript"

Browse Popular Code Answers by Language