Open nadirhussainnn opened 3 years ago
npx create-react-app my-project cd my-project
npm install -D tailwindcss@npm:@tailwindcss/postcss7-compat postcss@^7 autoprefixer@^9
npm install @craco/craco
And change your package.json as
package.json
Create craco.config.js named file with package.json file level as
craco.config.js
Then add this code in craco.config.js file // craco.config.js module.exports = { style: { postcss: { plugins: [ require('tailwindcss'), require('autoprefixer'), ], }, }, }
// craco.config.js module.exports = { style: { postcss: { plugins: [ require('tailwindcss'), require('autoprefixer'), ], }, }, }
Execute npx tailwindcss-cli@latest init command in terminal, it will create tailwind.config.js file as
npx tailwindcss-cli@latest init
create tailwind.config.js
Put this code in tailwind.config.js file
tailwind.config.js
module.exports = { purge: ['./src/**/*.{js,jsx,ts,tsx}', './public/index.html'], darkMode: false, // or 'media' or 'class' theme: { extend: {}, }, variants: { extend: {}, }, plugins: [ require('@tailwindcss/forms'), ], } Now in index.css file remove whole css code and put
module.exports = { purge: ['./src/**/*.{js,jsx,ts,tsx}', './public/index.html'], darkMode: false, // or 'media' or 'class' theme: { extend: {}, }, variants: { extend: {}, }, plugins: [ require('@tailwindcss/forms'), ], }
index.css
/* ./src/index.css */ @tailwind base; @tailwind components; @tailwind utilities; like
/* ./src/index.css */ @tailwind base; @tailwind components; @tailwind utilities;
import index.css in index.js (imported by default).
Now install npm install @headlessui/react @heroicons/react and npm i @tailwindcss/forms
npm install @headlessui/react @heroicons/react
npm i @tailwindcss/forms
and use import tailwindcss/tailwind.css in App.js as
import tailwindcss/tailwind.css
YOU ARE READY TO USE tailwind ui and tailwind css in your project.
npx create-react-app my-project cd my-project
npm install -D tailwindcss@npm:@tailwindcss/postcss7-compat postcss@^7 autoprefixer@^9
npm install @craco/craco
And change your
package.json
asCreate
craco.config.js
named file with package.json file level asThen add this code in
craco.config.js
file// craco.config.js module.exports = { style: { postcss: { plugins: [ require('tailwindcss'), require('autoprefixer'), ], }, }, }
Execute
npx tailwindcss-cli@latest init
command in terminal, it willcreate tailwind.config.js
file asPut this code in
tailwind.config.js
filemodule.exports = { purge: ['./src/**/*.{js,jsx,ts,tsx}', './public/index.html'], darkMode: false, // or 'media' or 'class' theme: { extend: {}, }, variants: { extend: {}, }, plugins: [ require('@tailwindcss/forms'), ], }
Now inindex.css
file remove whole css code and put/* ./src/index.css */ @tailwind base; @tailwind components; @tailwind utilities;
likeimport index.css in index.js (imported by default).
Now install
npm install @headlessui/react @heroicons/react
andnpm i @tailwindcss/forms
and use
import tailwindcss/tailwind.css
in App.js asYOU ARE READY TO USE tailwind ui and tailwind css in your project.