前端项目支持tailwindcss写样式

  • 安装
shell 复制代码
npm install -D tailwindcss
npx tailwindcss init
  • 配置 tailwind.config.js
shell 复制代码
//根据个人需求填写,比如vue简单配置
/** @type {import('tailwindcss').Config} */
module.exports = {
  darkMode: "class",
  corePlugins: {
    preflight: false
  },
  content: ["./index.html", "./src/**/*.{vue,js,ts,jsx,tsx}"],
  theme: {
    extend: {
      colors: {
        bg_color: "var(--el-bg-color)",
        primary: "var(--el-color-primary)",
        primary_light_9: "var(--el-color-primary-light-9)",
        text_color_primary: "var(--el-text-color-primary)",
        text_color_regular: "var(--el-text-color-regular)",
        text_color_disabled: "var(--el-text-color-disabled)"
      }
    }
  }
};
  • Tailwind 的指令添加到你的 CSS 文件中,可以新建css文件并贴入以下代码,并且在main文件种引入该css
shell 复制代码
@tailwind base;
@tailwind components;
@tailwind utilities;
  • postcss.config.js 调整
shell 复制代码
export default {
	plugins: {
		tailwindcss: {},
		autoprefixer: {}
	}
};

现在就可以在你的项目种直接使用tailwindcss,附上官网链接:tailwindcss

相关推荐
独泪了无痕2 小时前
使用Fetch API 探索前后端数据交互
前端·http·交互设计
css趣多多2 小时前
别名路径的知识点
前端
靓仔建4 小时前
Vue3导入组件出错does not provide an export named ‘user_setting‘ (at index.vue:180:10)
开发语言·前端·typescript
EnoYao4 小时前
我写了一个团队体检报告 Skill,把摸鱼的同事扒出来了😅
前端·javascript
梁正雄4 小时前
Python前端-2-css练习
前端·css·python
清汤饺子4 小时前
用 Cursor 半年了,效率还是没提升?是因为你没用对这 7 个功能
前端·后端·cursor
蓝莓味的口香糖5 小时前
【vue3】组件的批量全局注册
前端·javascript·vue.js
wefly20175 小时前
开发者效率神器!jsontop.cn一站式工具集,覆盖开发全流程高频需求
前端·后端·python·django·flask·前端开发工具·后端开发工具
独泪了无痕5 小时前
自动导入 AutoImport:告别手动引入依赖,优化Vue3开发体验
前端·vue.js·typescript
GDAL5 小时前
MANIFEST.in简介
linux·服务器·前端·python