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 從公開儲存庫中收錄這些內容。

檢舉或申請下架