Custom Fonts not working #13583
-
Hi everyone When I try to add a custom font with font-face it seems that tailwindcss can not find it and show it properly. I have tried anything I could think of and as of now I have my index.css file in the src folder which in there I have defined my fonts in the base layer using @font-face Also in my tailwind.config,js file I have extended the font family that I need. But when I use it in App.jsx it does not work and does not show the font that I have defined using font-face I would really appreciate your help Also here is the repo so you can check it out yourself: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
As per the syntax for @layer base {
@font-face {
font-family: "Ubuntu";
font-weight: 400;
- src: url("../public/fonts/Ubuntu-Regular.ttf") format("ttf");
+ src: url("../public/fonts/Ubuntu-Regular.ttf") format("truetype");
}
@font-face {
font-family: "Ubuntu";
font-weight: 500;
- src: url("../public/fonts/Ubuntu-Medium.ttf") format("ttf");
+ src: url("../public/fonts/Ubuntu-Medium.ttf") format("truetype");
}
@font-face {
font-family: "Ubuntu";
font-weight: 700;
- src: url("../public/fonts/Ubuntu-Bold.ttf") format("ttf");
+ src: url("../public/fonts/Ubuntu-Bold.ttf") format("truetype");
} You may also wish to consider changing the paths to the recommended @layer base {
@font-face {
font-family: "Ubuntu";
font-weight: 400;
- src: url("../public/fonts/Ubuntu-Regular.ttf") format("truetype");
+ src: url("/fonts/Ubuntu-Regular.ttf") format("truetype");
}
@font-face {
font-family: "Ubuntu";
font-weight: 500;
- src: url("../public/fonts/Ubuntu-Medium.ttf") format("truetype");
+ src: url("/fonts/Ubuntu-Medium.ttf") format("truetype");
}
@font-face {
font-family: "Ubuntu";
font-weight: 700;
- src: url("../public/fonts/Ubuntu-Bold.ttf") format("truetype");
+ src: url("/fonts/Ubuntu-Bold.ttf") format("truetype");
} Or move them inside the |
Beta Was this translation helpful? Give feedback.
As per the syntax for
src
in@font-face
according to MDN, you'd wanttruetype
, notttf
for theformat()
values: