-1

I want to add some custom / local fonts to my react project, can anyone tell me the method to use it inside react project ?

Below I have added some ss of my code which is not working.

index.js

index.css

app.scss

Thanks

Adarsh
  • 75
  • 1
  • 5

1 Answers1

0

You import the bold font in your index.js but you set the book font in your App.scss. Also try to add !important when setting the font-family on the body:

html,
body {
  font-family: "CooperHewitt-Bold" !important;
}

Using @font-face:

/* index.css */ 
@font-face {
  font-family: "CooperHewitt-Bold";
  src: local("CooperHewitt-Bold"),
    url(./fonts/CooperHewitt-Bold.otf) format("opentype");
}

Make sure to import index.css inside index.js:

import './index.css';
// ...
5eb
  • 14,798
  • 5
  • 21
  • 65