I was working on project where I used React, Next.js with Tailwind CSS, and I did some customization in styling, like used react-slick for slider, and I applied custom CSS to react-slick slider classes and made slider as I want to... but meanwhile I am trying to apply default custom fonts to my entire project. In that case, I made some changes in the file of
theme: {
fontFamily: {
customfontname: ['Segoe UI', 'Helvetica Neue', 'Arial', 'sans-serif', ...defaultTheme.fontFamily.customfontname],
},
extend: {},
},
After that, I got a compile error:
./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[2].oneOf[7].use[1]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[2].oneOf[7].use[2]!./node_modules/slick-carousel/slick/slick-theme.css
ReferenceError: defaultTheme is not defined
/** @type {import('tailwindcss').Config} */
module.exports = {
mode: "jit",
content: [
"./pages/**/*.{js,ts,jsx,tsx}",
"./page-section/**/*.{js,ts,jsx,tsx}",
"./page-section/**/**/*.{js,ts,jsx,tsx}",
],
theme: {
fontFamily: {
customfontname: ['Segoe UI', 'Helvetica Neue', 'Arial', 'sans-serif', ...defaultTheme.fontFamily.customfontname],
},
extend: {
fontFamily: {
customfontname: ['Segoe UI',
'Helvetica Neue',
'Arial',
'sans-serif',
...defaultTheme.fontFamily.customfontname],
},
}
},
plugins: [],
};
This is the code of people who trying to help me, but I getting the same error as I mentioned...
/** @type {import('tailwindcss').Config} */
const defaultTheme = require("tailwindcss/defaultTheme");
module.exports = {
mode: "jit",
content: [
"./pages/**/*.{js,ts,jsx,tsx}",
"./page-section/**/*.{js,ts,jsx,tsx}",
"./page-section/**/**/*.{js,ts,jsx,tsx}",
],
theme: {
fontFamily: {
customfontname: [
"Segoe UI",
"Helvetica Neue",
"Arial",
"sans-serif",
...defaultTheme.fontFamily.customfontname,
],
},
extend: {},
},
plugins: [],
};
Add your customfontname inside extend of your theme
const defaultTheme = require('tailwindcss/defaultTheme')
module.exports = {
theme: {
extend: { // 👈 Add it inside this
fontFamily: {
customfontname: ['Segoe UI',
'Helvetica Neue',
'Arial',
'sans-serif',
/*...*/ defaultTheme.fontFamily.customfontname],
},
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With