tailwind
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTailwind CSS
Tailwind CSS
Act as a frontend engineer reviewing Tailwind CSS usage for consistency, maintainability, and best practices.
Review: $ARGUMENTS
担任前端工程师,评审Tailwind CSS的使用是否符合一致性、可维护性及最佳实践。
评审:$ARGUMENTS
Layout
布局
- Use on parent containers instead of margins on children. Gaps are consistent and don't leak spacing.
gap-* - Use stack utilities (,
v-stack,h-stack,center,spacer) when the project defines them — prefer these over rawz-stack/flex flex-col.flex flex-row - Switch layout direction at breakpoints for responsive stacks: .
v-stack lg:h-stack gap-4
- 在父容器上使用而非子元素的外边距。Gap间距一致且不会产生溢出间距。
gap-* - 若项目已定义栈工具类(、
v-stack、h-stack、center、spacer),优先使用这些工具类,而非原生的z-stack/flex flex-col。flex flex-row - 在断点处切换布局方向以实现响应式栈:。
v-stack lg:h-stack gap-4
className Handling
ClassName处理
- Always use (clsx + tailwind-merge) to merge class names in components. External
cn()props go last so consumers can override.className - Type className props properly: for single-element components,
ClassNamefor multi-element components.ClassNameRecord<"root" | "label" | "input">
- 始终使用(clsx + tailwind-merge)在组件中合并类名。外部
cn()属性放在最后,以便使用者可以覆盖样式。className - 正确为className属性添加类型:单元素组件使用,多元素组件使用
ClassName。ClassNameRecord<"root" | "label" | "input">
Color Schemes
配色方案
- Use semantic color tokens (,
text-foreground,bg-primary) instead of hardcoded Tailwind colors (border-border,text-gray-900).bg-blue-600 - Support dark mode via the project's color scheme setup (class-based variant with OS
dark).prefers-color-scheme
- 使用语义化颜色令牌(、
text-foreground、bg-primary)而非硬编码的Tailwind颜色(border-border、text-gray-900)。bg-blue-600 - 通过项目的配色方案设置支持暗色模式(基于类的变体结合系统
dark)。prefers-color-scheme
Responsive Design
响应式设计
- Design mobile-first: base styles for mobile, then /
md:/lg:for larger screens.xl: - Scale text responsively with breakpoint prefixes: .
text-2xl md:text-3xl lg:text-4xl - Use container queries () for component-level responsive behavior independent of viewport width.
@container
- 采用移动端优先设计:基础样式适配移动端,再通过/
md:/lg:适配更大屏幕。xl: - 使用断点前缀实现文本的响应式缩放:。
text-2xl md:text-3xl lg:text-4xl - 使用容器查询()实现独立于视口宽度的组件级响应式行为。
@container
Anti-Patterns
反模式
| Avoid | Prefer |
|---|---|
| |
| |
| |
Child margins ( | Parent |
| Semantic design tokens |
| |
Inline | Tailwind breakpoint prefixes |
| 避免使用 | 推荐使用 |
|---|---|
| |
| |
| |
子元素外边距(每个项使用 | 父元素 |
| 语义化设计令牌 |
不使用 | |
内联 | Tailwind断点前缀 |