xxxxxxxxxx
//Open your terminal and navigate to the desired directory where you want to create the project.
//Run the following command to create a new React app using Create React App, with Tailwind CSS included:
npx create-react-app my-app --template cra-template-tailwindcss
//Replace my-app with the desired name of your project.
//Once the React app is created, navigate into the project directory:
//Insert in Terminal:
cd my-app
Install Tailwind CSS
Install tailwindcss via npm, and then run the init command to generate your tailwind.config.js file.
xxxxxxxxxx
npm install -D tailwindcss
npx tailwindcss init
Configure your template paths
Add the paths to all of your template files in your tailwind.config.js file.
xxxxxxxxxx
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
Add the Tailwind directives to your CSS
Add the @tailwind directives for each of Tailwind’s layers to your ./src/index.css file.
xxxxxxxxxx
@tailwind base;
@tailwind components;
@tailwind utilities;
Start your build process
Run your build process with npm run start.
xxxxxxxxxx
npm run start
xxxxxxxxxx
1) Install in your project
npm install -D tailwindcss postcss autoprefixer
2) Install tailwindcss and its peer
dependencies via npm, and then run
the init command to generate both
tailwind.config.js and postcss.config.js.
"npx tailwindcss init -p"
3) Configure your template paths.
Add the paths to all of your template
files in your tailwind.config.js file.
"module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}"
4) Add the Tailwind directives to your CSS
Add the @tailwind directives for each of Tailwind’s
layers to your ./src/index.css file.
"@tailwind base;"
"@tailwind components;"
"@tailwind utilities;"
xxxxxxxxxx
react tailwind configer
Step-1
install two item=>
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
Step-2 write this code in tailwind.config.js file
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
Step-3
put this code top index.css file
@tailwind base;
@tailwind components;
@tailwind utilities;
Step-4
run your Project
npm run start
Install Tailwind CSS with Create React App
xxxxxxxxxx
1. npx create-react-app my-project
2. cd my-project
3. npm install -D tailwindcss
4. npx tailwindcss init
5. Add the paths to all of your template files
in your tailwind.config.js file.
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
6. Add the @tailwind directives for each of
Tailwind’s layers to your ./src/index.css file.
@tailwind base;
@tailwind components;
@tailwind utilities;
7. npm run start
xxxxxxxxxx
@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";
xxxxxxxxxx
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
xxxxxxxxxx
npm install tailwindcss postcss-cli autoprefixer@9.8.6 -D
xxxxxxxxxx
import React from 'react';
import ReactDOM from 'react-dom';
import { Button } from 'react-tailwindcss-components';
function App() {
return (
<Button className="shadow-2xl border-green-400 bg-green-400 rounded font-bold text-white">
Hello World
</Button>
);
}
ReactDOM.render(<App />, document.querySelector('#app'));
xxxxxxxxxx
/* ./src/index.css */
@tailwind base;
@tailwind components;
@tailwind utilities;