Reputation: 43
i am using tailwind css + next js. i am unable to import static font from /fonts/rubik.woff2 file
//gobals.css
@tailwind base;
@tailwind components;
@tailwind utilities;
@fontface {
font-family: "rubik";
font-style: normal;
font-weight: 400;
font-display: fallback;
src: url(/fonts/rubik.woff2) format("woff2");
}
//tailwind.config.js
module.exports = {
content: [
"./app/**/*.{js,ts,jsx,tsx}",
"./pages/**/*.{js,ts,jsx,tsx}",
"./components/**/*.{js,ts,jsx,tsx}",
],
theme: {
FontFace: {},
fontFamily: {
home: ["rubik", "cursive"],
},
},
plugins: [],
};
can anyone tell me what i am doing wrong?
sandBox:- https://codesandbox.io/s/suspicious-frost-ujdocz?file=/src/styles.css
I have tried almost everything in my knowledge but i am unable to make it work. The project file structure
Upvotes: 3
Views: 576
Reputation: 932
Below are the steps you can follow, have created a StackBlitz example https://stackblitz.com/edit/github-9aq3v4-ozdwn4?file=styles%2Fglobals.css
tailwind.config.js
theme: {
extend: {
fontFamily: {
Rubik: ['Rubik'],
},
},
},
@font-face {
font-family: 'Rubik';
src: url('../fonts/Rubik-Regular.ttf');
font-weight: normal;
font-style: normal;
}
<h1 className="text-6xl font-Rubik">
Hello
</h1>
Upvotes: 2