Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

create react app and tailwind

1. npx create-react-app .

2. npm i -D tailwindcss postcss-cli autoprefixer 
or
npm install tailwindcss@latest postcss@latest autoprefixer@latest
//postcss - transform our compile css 
// autoprefixer - set vendor prefixes within our css automatically when needed

//Generate npc config file
3.npx tailwind init tailwind.js --full

// Create post css config file
4. touch postcss.config.js

//open postcss.config.js
//add this to the file
__________________________________________
const tailwindcss = require('tailwindcss');
module.exports = {
  plugins: [
    tailwindcss('./tailwind.js'),
    require('autoprefixer')
  ]
}
__________________________________________

5. inside scr, create assets folder src/assets
- create tailwind.css and main.css

in tailwind, add this code
//this will compile to the main css that will include in our app
___________________________________________
@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";
___________________________________________

6. Open package.json and add this iside the scripts
___________________________________________
   "start": "npm run watch:css && react-scripts start",
    "build": "npm run build:css && react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "build:css": "postcss src/assets/tailwind.css -o src/assets/main.css",
    "watch:css": "postcss src/assets/tailwind.css -o src/assets/main.css"
____________________________________________
7. run 'npm start'


add this to index.js
_____________________________________
import React from 'react';
import ReactDOM from 'react-dom';
import './assets/main.css';
import App from './App';

ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  document.getElementById('root')
);
_________________________________


install router

1. npm i --save react-router-dom
Comment

create react app with tailwind

1. Create React Project
	npx create-react-app my-project
	cd my-project
  
2. Install Tailwind CSS
	npm install -D tailwindcss postcss autoprefixer
	npx tailwindcss init -p

3. Configure your template paths
	add the following code to your `tailwind.config.js` file:
   	content: [
    	"./src/**/*.{js,jsx,ts,tsx}",
  	],

4. Add the Tailwind directives to your CSS
	add the following code to your `./src/index.css` file:
	@tailwind base;
	@tailwind components;
	@tailwind utilities;

5. Start your build process
	npm run start
Comment

Add tailwind to create react app

npx create-react-app my-project
cd my-project
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
# Update the tailwind.config.js
module.exports = {
  content: [
    "./src/**/*.{js,jsx,ts,tsx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}
# Add this to index.{less,sass,scss,css}
@tailwind base;
@tailwind components;
@tailwind utilities;
Comment

create react tailwind app

npx create-react-tailwind-app
Comment

PREVIOUS NEXT
Code Example
Javascript :: string split javascript 
Javascript :: Changing the img src using jQuery. 
Javascript :: two decimel javascript 
Javascript :: postman Assign variable to pre request script 
Javascript :: js for in object 
Javascript :: get document jquery 
Javascript :: change value of drop down using jquery 
Javascript :: javascript if input number empty then make 0 
Javascript :: Convert from JSON to Python 
Javascript :: dropzone on success all files 
Javascript :: sequelize sync 
Javascript :: javascript range of integers with spread 
Javascript :: nestjs change httpcode inside function 
Javascript :: check if type is blob javascript 
Javascript :: unique string id js 
Javascript :: how to validate a string using regular expression in javascript 
Javascript :: get datetime yesterday angular 
Javascript :: navigator.clipboard is undefined 
Javascript :: dynamic copyright year js 
Javascript :: npm uniqueid 
Javascript :: js get all indexes of value in array 
Javascript :: get value json python 
Javascript :: material ui location icon 
Javascript :: for htmlcollection javascript 
Javascript :: jquery remove duplicates from array 
Javascript :: convert json to dataframe python 
Javascript :: queryselectorall data attribute 
Javascript :: how to convert kilomer to meter in javascript 
Javascript :: javascript function required arguments 
Javascript :: any click event jquery 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =