如果您还没有 react 应用程序,请创建一个:
1
2
npx create-react-app my-app
cd my-app
1
npm install -d tailwindcss postcss autoprefixer
然后初始化 tailwind css:
1
npx tailwindcss init
这将在您的项目中创建一个 tailwind.config.js 文件。
配置 tailwind 编辑 tailwind.config.js 文件以配置内容路径。将内容密钥替换为以下内容:1
2
3
4
5
6
7
8
9
10
/** @type {import(tailwindcss).config} */
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}", // scan these files for tailwind classes
],
theme: {
extend: {},
},
plugins: [],
};
1
2
3
@tailwind base;
@tailwind components;
@tailwind utilities;
1
import ./index.css;
1
npm start
以上就是在 React JS 项目中设置 Tailwind CSS的详细内容,更多请关注php中文网其它相关文章!