DEV Community

Cover image for Adding downloaded fonts in your React app
Roopali Singh
Roopali Singh

Posted on • Edited on

25 4

Adding downloaded fonts in your React app

Hola amigos👋,

There exist fonts which can't be found on Google Fonts.
And now you're left with no other option but to download and import them in the code on your own.

Lucky You🍀 It's not that difficult to add downloaded fonts in the React App.

You just need to follow these 4 steps:

1. Create a fonts folder in the src folder of your React app.

2. Add the downloaded fonts in the fonts folder created.

The Folder Structure would look something like this:

Folder Structure

3. In the index.css file, write the following lines of code:



/* In index.css */

@font-face {
  font-family: "GilroyRegular";
  src: local("GilroyRegular"),
    url("./fonts/Gilroy-Regular.otf") format("opentype");
  font-weight: normal;
}

/* Other font formats include:
'woff2', 'truetype, 'woff', 'embedded-opentype', and 'svg' */


Enter fullscreen mode Exit fullscreen mode

4. Import the index.css file in the index.js file.



// In index.js

import "./index.css";


Enter fullscreen mode Exit fullscreen mode

Now to use it, you just need to add the following css:



/* In any .css file */

.selector {
font-family: "GilroyRegular";
font-style: italic;
}


Enter fullscreen mode Exit fullscreen mode

😃Whoa!
We have successfully integrated the downloaded font in our webapp🔥

Task Completed

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)

Cloudinary image

Optimize, customize, deliver, manage and analyze your images.

Remove background in all your web images at the same time, use outpainting to expand images with matching content, remove objects via open-set object detection and fill, recolor, crop, resize... Discover these and hundreds more ways to manage your web images and videos on a scale.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay