Once you have installed Tailwind CSS, in your gatsby-config.js file, enable the gatsby-plugin-postcss.
module.exports = {
plugins: [
'gatsby-plugin-postcss',
// ...
],
}
module.exports = {
plugins: [
'gatsby-plugin-postcss',
// ...
],
}
#Configure Your Template Paths
Next, you need to configure your template paths in your tailwind.config.js file.
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/pages/**/*.{js,jsx,ts,tsx}",
"./src/components/**/*.{js,jsx,ts,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/pages/**/*.{js,jsx,ts,tsx}",
"./src/components/**/*.{js,jsx,ts,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
#Add Tailwind CSS Directives to CSS
Next, create a ./src/styles/global.css file and add the @tailwind directives for each of Tailwind's layers.
@tailwind base;
@tailwind components;
@tailwind utilities;
@tailwind base;
@tailwind components;
@tailwind utilities;
#Import CSS File
Next, create a gatsby-browser.js file at the root of your project if it doesn't already exist, and import your newly-created ./src/styles/global.css file.
import './src/styles/global.css'
import './src/styles/global.css'
#Install Material Tailwind
Once you installed and configured Tailwind CSS, you need to install @material-tailwind/react by running the following command:
npm i @material-tailwind/react@beta
npm i @material-tailwind/react@beta
#Add Plugin and Template Path
Once you installed @material-tailwind/react you need to add mtConfig and the template path to your tailwind.config.js file.