AgentSkillsCN

refactoring-ui

当您需要进行 UI 设计、选择配色方案、确定排版风格与间距比例、构建视觉层级,或做出各类设计决策时,此技能将以 Wathan & Schoger 的《重构 UI》为理论基础。

SKILL.md
--- frontmatter
name: refactoring-ui
description: Use when designing UI, choosing colors, typography, spacing, creating visual hierarchy, or making design decisions. Based on Refactoring UI by Wathan & Schoger.

Refactoring UI

Practical UI design principles from Refactoring UI (Wathan & Schoger).

Starting From Scratch

  • Don't design in grayscale - Work with real colors; grayscale hides hierarchy problems
  • Start with a feature, not a layout - Build the actual UI, not the shell
  • Detail comes later - Start low-fidelity
  • Design in cycles - Short iterations, don't finish everything at once

Hierarchy (Most Important)

Visual hierarchy determines what users see first.

TechniquePrimarySecondaryTertiary
ColorDark/blackGreyLight grey
WeightBold (600-700)Normal (400-500)Normal/Light
SizeLargerBaseSmaller

Rules:

  • Size isn't everything - combine weight + color + size
  • De-emphasize by reducing contrast
  • Labels are last resort - data often speaks for itself
  • Balance weight and contrast - icons may need reduced contrast next to text

Spacing & Layout

Spacing scale (px): 4, 8, 12, 16, 24, 32, 48, 64, 96

Rules:

  • Start with too much white space - remove later
  • Use a defined scale, not arbitrary values
  • Don't fill the whole screen - elements need only the space they need
  • Grids are overrated - don't force 12 columns
  • Avoid ambiguous spacing - related things closer together

Typography

Type scale: Limit to defined set of sizes (e.g., 12, 14, 16, 18, 20, 24, 30, 36, 48)

ContextLine HeightLetter Spacing
Headings1.2-1.25Tighter (-0.02em)
Body text1.5-1.75Normal
All-caps-Wider (+0.05em)

Rules:

  • 45-75 characters per line
  • Align mixed sizes to baseline, not center
  • Left-align most text; center only short independent blocks
  • Not all links need color - context makes them obvious

Color

Use HSL, not hex - Easier to manipulate.

Building a Palette

  1. Pick base color (middle of range)
  2. Pick darkest and lightest shades
  3. Fill in gaps (5-10 shades per color)

Palette structure:

  • Greys: 8-10 shades (add subtle saturation for personality - cool blue, warm brown)
  • Primary: 5-10 shades
  • Accents: 5-10 shades each

Rules:

  • Define shades upfront, don't pick on the fly
  • Accessible doesn't mean ugly - use color strategically
  • Don't rely only on color - support colorblindness with icons/text

Depth & Shadows

Shadow scale: Define a set like spacing (e.g., sm, md, lg, xl)

ElevationShadowUse Case
RaisedSmall, sharpButtons
FloatingMedium, softerDropdowns, cards
ModalLarge, diffuseModals, dialogs

Techniques:

  • Two shadows > one (ambient + direct light)
  • Tinted shadows look more natural
  • Overlap elements for depth without shadows
  • Lighter elements appear closer

Images & Icons

  • Text on images: Add overlay, gradient, shadow, or blur
  • Don't scale up icons - Use larger icons or put in a shape
  • Don't scale down screenshots - Use partial/cropped views
  • User-uploaded content: Set constraints, add backgrounds

Finishing Touches

Small details that elevate designs:

DefaultUpgraded
BulletsIcons
Plain underlinesCustom styled
Block quotesColored background + left border
BordersBox shadows or different backgrounds
Plain tablesNo lines, zebra stripes, or subtle dividers
Plain dropdownsIcons, descriptions
Plain radiosCards

Quick wins:

  • Accent borders (top of cards, left of alerts)
  • Subtle background patterns or gradients
  • Design empty states intentionally

Anti-Patterns

BadGood
Grayscale first, color laterColor from the start
Rely only on font sizeCombine size + weight + color
Fill entire screen widthConstrain to needed space
Arbitrary spacing valuesDefined spacing scale
Pick colors on the flyPre-defined palette
Generic "Loading..."Progressive messages or skeleton
Borders everywhereShadows, spacing, or backgrounds

Source

Refactoring UI by Adam Wathan & Steve Schoger (2018)