前端项目支持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

相关推荐
漫随流水1 小时前
旅游推荐系统(view.py)
前端·数据库·python·旅游
踩着两条虫2 小时前
VTJ.PRO 核心架构全公开!从设计稿到代码,揭秘AI智能体如何“听懂人话”
前端·vue.js·ai编程
jzlhll1233 小时前
kotlin Flow first() last()总结
开发语言·前端·kotlin
蓝冰凌4 小时前
Vue 3 中 defineExpose 的行为【defineExpose暴露ref变量】详解:自动解包、响应性与实际使用
前端·javascript·vue.js
奔跑的呱呱牛4 小时前
generate-route-vue基于文件系统的 Vue Router 动态路由生成工具
前端·javascript·vue.js
柳杉4 小时前
从动漫水面到赛博飞船:这位开发者的Three.js作品太惊艳了
前端·javascript·数据可视化
Greg_Zhong5 小时前
前端基础知识实践总结,每日更新一点...
前端·前端基础·每日学习归类
We་ct5 小时前
LeetCode 148. 排序链表:归并排序详解
前端·数据结构·算法·leetcode·链表·typescript·排序算法
IT_陈寒5 小时前
JavaScript开发者必看:5个让你的代码性能翻倍的隐藏技巧
前端·人工智能·后端