DekGenius.com
CSS
how to install tailwind for react
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;"
how to properly install tailwind css in react
@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";
how to properly install tailwind css in react
npx tailwind init tailwind.js --full
how to properly install tailwind css in react
npm install tailwindcss postcss-cli autoprefixer@9.8.6 -D
tailwind css in react
/* ./src/index.css */
@tailwind base;
@tailwind components;
@tailwind utilities;
Setup Tailwind CSS in react-native or react
// tailwind.config.js
module.exports = {
- content: [],
+ content: ["./App.{js,jsx,ts,tsx}", "./src/**/*.{js,jsx,ts,tsx}"],
theme: {
extend: {},
},
plugins: [],
}
react tailwind css components npm
// with npm
npm install react-tailwindcss-components
// with yarn
yarn add react-tailwindcss-components
react tailwind css components npm
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'));
tailwind css in react
npx create-react-app my-project
cd my-project
how to properly install tailwind css in react
const tailwindcss = require('tailwindcss');
module.exports = {
plugins: [
tailwindcss('./tailwind.js'),
require('autoprefixer')
],
};
tailwind css in react
// tailwind.config.js
module.exports = {
- purge: [],
+ purge: ['./src/**/*.{js,jsx,ts,tsx}', './public/index.html'],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
},
variants: {
extend: {},
},
plugins: [],
}
tailwind css and react
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
how to properly install tailwind css in react
"scripts": {
"start": "npm run watch:css && react-scripts start",
"build": "npm run watch:css && react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"watch:css": "postcss src/assets/tailwind.css -o src/assets/main.css"
}
tailwind css in react
// tailwind.config.js
module.exports = {
purge: [],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
},
variants: {
extend: {},
},
plugins: [],
}
how to properly install tailwind css in react
setup tailwind css with react
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
how to properly install tailwind css in react
npx create-react-app react-tailwindcss && cd react-tailwindcss
© 2022 Copyright:
DekGenius.com