Tailwind Ui Refactor

作者 pproencacf93c57cac89无许可证215 个星标收录于 2026年10月8日更新于 2026年10月8日仓库7周前更新

Refactoring UI design patterns for Tailwind CSS applications. This skill should be used when writing, reviewing, or refactoring HTML with Tailwind utility classes to improve visual hierarchy, spacing, typography, color, depth, and polish. Triggers on tasks involving UI cleanup, design review, Tailwind refactoring, component styling, or visual improvements.

AI 生成的概览

包含 52 条规则的 Tailwind CSS 界面重构指南,涵盖层级、间距、排版、色彩、层次与细节。

功能
提供按设计影响排序的 52 条设计规则,用于重构或编写使用 Tailwind CSS 工具类样式的 HTML,规则分为从设计意图到细节打磨的九个类别。每条规则都有独立的参考文件,包含说明和代码示例,技能还附带规则模板和分类定义。它只提供指导,本身不生成文件或代码。
适用场景
适用于清理、审查或重构 Tailwind CSS 组件和页面时,也适用于编写新界面标记并希望改善视觉层级、间距、排版、色彩和层次感时。它还可用于修复现有界面中的对比度和无障碍问题。
运行要求
不需要脚本或软件包,仅为说明文档和参考文件。智能体需要能读取该技能的参考文件,目标项目应使用 Tailwind CSS(v4 语法,部分内容附 v3 说明)。

Refactoring UI Tailwind CSS Best Practices

Comprehensive UI refactoring guide based on Refactoring UI by Adam Wathan & Steve Schoger, implemented with Tailwind CSS utility classes. Contains 52 rules across 9 categories, prioritized by design impact to guide automated refactoring and code generation. Uses Tailwind CSS v4 syntax (v3 notes provided where syntax differs).

Important: Think first, style second. Before applying any visual rule, understand the UI's purpose, identify what matters to the user, and remove unnecessary elements. The Design Intent category (priority 1) must be considered before any styling changes. A simpler component with fewer elements always beats a decorated component with unnecessary markup.

When to Apply

Reference these guidelines when:

  • Refactoring existing Tailwind CSS components
  • Writing new UI with Tailwind utility classes
  • Reviewing code for visual hierarchy and spacing issues
  • Improving design quality without a designer
  • Fixing accessibility contrast problems

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Design IntentCRITICALintent-
2Visual HierarchyCRITICALhier-
3Layout & SpacingCRITICALspace-
4TypographyHIGHtype-
5Color SystemsHIGHcolor-
6Depth & ShadowsMEDIUMdepth-
7Borders & SeparationMEDIUMsep-
8Images & ContentLOW-MEDIUMimg-
9Polish & DetailsLOWpolish-

Quick Reference

1. Design Intent (CRITICAL)

  • intent-audit-before-styling [blocked] - Audit what each element communicates before changing any CSS
  • intent-remove-before-decorating [blocked] - Remove unnecessary elements before styling what remains
  • intent-reduce-cognitive-load [blocked] - Reduce choices per screen — fewer options beat prettier options
  • intent-progressive-disclosure [blocked] - Hide secondary information behind interactions
  • intent-content-drives-layout [blocked] - Let real content determine layout — not the other way around
  • intent-simplify-over-decorate [blocked] - Prefer removing a wrapper over adding 5 utility classes to it
  • intent-match-context-fidelity [blocked] - Match design polish to context — admin vs consumer vs product
  • intent-match-existing-patterns [blocked] - Audit sibling component patterns before restyling

2. Visual Hierarchy (CRITICAL)

  • hier-size-weight-color [blocked] - Use size, weight, and color for hierarchy — not just size
  • hier-deemphasize-secondary [blocked] - De-emphasize secondary content instead of emphasizing primary
  • hier-button-hierarchy [blocked] - Style buttons by visual hierarchy, not semantic importance
  • hier-label-value-pairs [blocked] - Combine labels and values into natural language
  • hier-semantic-vs-visual [blocked] - Separate visual hierarchy from document hierarchy
  • hier-icon-sizing [blocked] - Size icons relative to adjacent text, not to fill space
  • hier-color-hierarchy-on-dark [blocked] - Use opacity or muted colors for hierarchy on colored backgrounds

3. Layout & Spacing (CRITICAL)

  • space-start-generous [blocked] - Start with too much whitespace, then remove
  • space-systematic-scale [blocked] - Use a constrained spacing scale, not arbitrary values
  • space-relationship-proximity [blocked] - Use spacing to show relationships between elements
  • space-dont-fill-screen [blocked] - Constrain content width — avoid filling the whole screen
  • space-grids-not-required [blocked] - Use fixed widths when grids are not needed
  • space-relative-sizing-fails [blocked] - Avoid raw viewport units without clamping
  • space-mobile-first [blocked] - Design mobile-first at ~400px, then expand

4. Typography (HIGH)

  • type-line-length [blocked] - Keep line length between 45-75 characters
  • type-line-height-inverse [blocked] - Line height and font size are inversely proportional
  • type-font-weight-variety [blocked] - Choose fonts with at least 5 weight variations
  • type-no-center-long-text [blocked] - Left-align body content — avoid centering long-form text
  • type-letter-spacing [blocked] - Tighten letter spacing for headlines, loosen for uppercase
  • type-align-numbers-right [blocked] - Align numbers right in tables for easy comparison

5. Color Systems (HIGH)

  • color-define-palette-upfront [blocked] - Define a complete color palette upfront — don't pick colors ad-hoc
  • color-grayscale-first [blocked] - Design in grayscale first, add color last
  • color-accessible-contrast [blocked] - Ensure 4.5:1 contrast ratio for body text
  • color-dark-gray-not-black [blocked] - Use dark gray instead of pure black for text
  • color-saturated-grays [blocked] - Add subtle saturation to grays for warmth or coolness
  • color-light-backgrounds-dark-text [blocked] - Use light-colored backgrounds with dark text for badges

6. Depth & Shadows (MEDIUM)

  • depth-shadow-scale [blocked] - Define a fixed shadow scale — small to extra large
  • depth-shadow-vertical-offset [blocked] - Use vertical offset for natural-looking shadows
  • depth-interactive-elevation [blocked] - Use shadow changes to communicate interactivity
  • depth-light-closer-dark-recedes [blocked] - Lighter colors feel closer, darker colors recede
  • depth-overlap-layers [blocked] - Overlap elements to create visual layers

7. Borders & Separation (MEDIUM)

  • sep-fewer-borders [blocked] - Use fewer borders — replace with spacing, shadows, or background color
  • sep-background-color-separation [blocked] - Use background color differences to separate sections
  • sep-table-spacing-not-lines [blocked] - Use spacing instead of lines in simple tables
  • sep-card-radio-buttons [blocked] - Upgrade radio buttons to selectable cards for key choices

8. Images & Content (LOW-MEDIUM)

  • img-control-user-content [blocked] - Control user-uploaded image size and aspect ratio
  • img-text-overlay [blocked] - Add overlays or reduce contrast for text over images
  • img-dont-scale-up-icons [blocked] - Avoid scaling up icons designed for small sizes
  • img-empty-states [blocked] - Design meaningful empty states with clear CTAs

9. Polish & Details (LOW)

  • polish-accent-borders [blocked] - Add accent borders to highlight important elements
  • polish-custom-bullets [blocked] - Replace default bullets with icons or checkmarks
  • polish-border-radius-personality [blocked] - Match border radius to brand personality
  • polish-gradient-close-hues [blocked] - Use gradients with hues within 30 degrees of each other
  • polish-inner-shadow-images [blocked] - Add inner shadow to prevent image background bleed

Scope & Limitations

This skill covers layout, hierarchy, spacing, color, and polish based on Refactoring UI principles. It does NOT cover:

  • Font selection & pairing — choosing distinctive typefaces, avoiding generic AI defaults (Inter, Arial, system-ui), or pairing display + body fonts
  • Animation & motion — meaningful transitions, micro-interactions, page load sequences, or scroll-triggered reveals
  • Creative direction — establishing an aesthetic vision, choosing a tone (minimal, maximalist, brutalist, etc.), or differentiating from generic "AI slop" aesthetics
  • Spatial composition — asymmetric layouts, grid-breaking elements, or unconventional visual flow

For these concerns, pair this skill with a design-thinking or frontend-design skill that covers creative direction and aesthetic execution.

How to Use

Read individual reference files for detailed explanations and code examples:

  • Section definitions [blocked] - Category structure and impact levels
  • Rule template [blocked] - Template for adding new rules

Reference Files

FileDescription
references/_sections.md [blocked]Category definitions and ordering
assets/templates/_template.md [blocked]Template for new rules
metadata.json [blocked]Version and reference information

来源与署名

来源:pproenca/dot-skills位于skills/.experimental/tailwind-ui-refactor提交cf93c57

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架