Last active
November 20, 2022 11:08
-
-
Save dnnysng/5bc61b2b85dd01ec1809367038b41bb0 to your computer and use it in GitHub Desktop.
Importing a Font to a React Project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* FONT_NAME = Your font name, i.e. Arial */ | |
/* PATH_TO_YOUR_FILE = The relative path to your font from index.css */ | |
/* Note: Most of the Google fonts I've seen are .ttf which is the 'truetype' format */ | |
@font-face { | |
font-family: 'FONT_NAME'; | |
src: local('FONT_NAME'), | |
url('PATH_TO_YOUR_FILE') format('truetype'); | |
} | |
/* Optionally you may also set other variables such as 'font-weight' while importing */ | |
/* In the example below the font will be used when you use a weight of '700' */ | |
@font-face { | |
font-family: 'FONT_NAME'; | |
src: local('FONT_NAME'), | |
url('PATH_TO_YOUR_FILE') format('truetype'); | |
font-weight: 700; | |
} | |
/* This is how you use the font */ | |
.selector { | |
font-family: 'FONT_NAME'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment