--- description: "Tailwind CSS 样式规范 — 类名顺序/响应式/暗色模式/主题桥接。管理端与 Element Plus 共存,用户端纯 Tailwind + Headless UI(禁止 Element Plus)" globs: - "**/*.vue" - "**/*.css" - "**/*.scss" alwaysApply: false --- # 🎨 Tailwind CSS Standards > **⚠️ 双前端区分**: > - **管理端** (`Case-Database-Frontend-admin/`):Tailwind + Element Plus 共存,下方「管理端专属」章节适用 > - **用户端** (`Case-Database-Frontend-user/`):纯 Tailwind + Headless UI,**禁止 Element Plus** ## 职责划分(管理端 — Tailwind + Element Plus 共存) | 层级 | 使用 Tailwind | 使用 Element Plus(仅管理端) | |------|--------------|------------------| | 页面布局 | `flex`, `grid`, `container`, spacing | - | | 间距/定位 | `p-*`, `m-*`, `absolute`, `relative` | - | | 表单控件 | - | `el-form`, `el-input`, `el-select` | | 数据展示 | - | `el-table`, `el-pagination`, `el-tag` | | 反馈组件 | - | `el-dialog`, `el-message`, `el-notification` | | 自定义 UI | 背景、边框、阴影、圆角 | - | | 文字排版 | `text-*`, `font-*`, `leading-*` | - | **管理端原则**: Element Plus 组件优先使用其 `size`/`type`/`effect` 等内置 props 控制样式; Tailwind 负责组件之间的布局、间距和非组件区域的装饰。 **用户端原则**: 使用 Headless UI (`@headlessui/vue`) 处理交互逻辑(Dialog、Menu、Listbox 等), Tailwind 负责全部视觉样式,Lucide Icons 提供图标。 ## 类名顺序 布局 → 定位 → 尺寸 → 间距 → 背景 → 边框 → 文字 → 效果 → 交互 → 动画 ```html class="flex items-center justify-between relative w-full h-10 px-4 py-2 bg-white border border-gray-200 rounded-lg text-sm text-gray-700 shadow-sm hover:bg-gray-50 focus:ring-2 transition-colors" ``` ## 响应式断点(移动优先) | 断点 | 前缀 | 最小宽度 | 典型设备 | |------|------|---------|---------| | xs (默认) | 无 | 0px | 手机竖屏 | | sm | `sm:` | 640px | 手机横屏 | | md | `md:` | 768px | 平板 | | lg | `lg:` | 1024px | 小屏桌面 | | xl | `xl:` | 1280px | 桌面 | | 2xl | `2xl:` | 1536px | 大屏桌面 | ```html