SuperAPI AI 工具集

tailwind-css-v4-mastery

前端与建站

查看项目

更新于 10-15 16:46

技能介绍

用途:该技能让 Claude 针对 Tailwind CSS V4(非 V3)提供专家指导,核心是“CSS 优先思维”——以 CSS 为唯一事实来源,取代 JavaScript 配置。

主要能力:

  1. 概念覆盖:Oxide(Rust)引擎取代 JS 解析器,构建速度较 v3 提升 10-100 倍,HMR 提升 15-30 倍;以 @theme {} 取代 tailwind.config.js;依赖 @property、color-mix()、CSS 嵌套等现代 CSS。浏览器要求 Safari 16.4+、Chrome 111+、Firefox 128+。
  2. 迁移工作流:审计配置、安装依赖、将 theme/extend 转为 @theme 变量、用 @import "tailwindcss" 替换 @tailwind 指令,并重构工具类(如 .shadow → .shadow-sm、.rounded → .rounded-sm、.outline-none → .outline-hidden、.bg-opacity-* → .bg-black/*)。安装命令:npm install -D tailwindcss@latest 及 npm install -D @tailwindcss/vite(或 @tailwindcss/postcss、@tailwindcss/cli)。
  3. 组件系统设计:在 @theme 中定义颜色、间距、字体变量,在 @layer components 中用 @apply 构建可复用类,并约定尺寸、状态、变体修饰符。
  4. 性能优化:按构建工具选择插件(Vite 用 @tailwindcss/vite,Webpack/PostCSS 用 @tailwindcss/postcss,无打包器用 @tailwindcss/cli),配合 Lightning CSS。

适用场景:V4 专属问答、组件系统与样式架构设计、V3→V4 迁移、性能优化、CSS-first 配置排障、设计系统搭建与自定义主题。不适用于 V3 及更早版本、非 Tailwind 领域问题、通用 CSS 教学或非 Web 项目;旧浏览器需留在 v3.4。

限制:资料为技能说明,未提供定价、平台或独立使用步骤;具体实践需结合项目实际验证。