04 apply consistent spacing

From gnurio/refactoring-ui-plugin · View interactive version

04 apply consistent spacing is an AI agent skill from the GitHub repository gnurio/refactoring-ui-plugin. Use systematic spacing with 25% minimum jumps, start with excess whitespace

How to use this skill

Skill file

Skill: Apply Consistent Spacing

Purpose

Use a systematic spacing scale to create rhythm, group related elements, and separate distinct sections while starting with generous whitespace and removing as needed.

Type

Generative + Evaluative

Input

Output

Transformation Performed

Maps spatial relationships to a systematic spacing scale with minimum 25% differences between values, ensuring clear grouping and breathing room.

Decision Criteria

PASS (Good Spacing)

FAIL (Poor Spacing)

The Spacing Scale

Systematic Scale (25% minimum jumps)

Base: 16px (browser default)

4px, 8px, 12px, 16px, 24px, 32px, 48px, 64px, 96px

Why these values:

Common Usage Patterns

| Spacing | Usage |

|---------|-------|

| 4px | Icon gaps, tight internal padding |

| 8px | Small component gaps, tight button padding |

| 12px | Input padding, component internal spacing |

| 16px | Standard gap, card padding |

| 24px | Section internal padding, larger gaps |

| 32px | Major section separation |

| 48-64px | Page section breaks |

| 96px | Hero sections, major page divisions |

The Proximity Principle

Key Principles

1. Start With Too Much Whitespace

Instead of adding space until something looks okay, start with way too much space and remove until it's right.

Why: Elements given minimum breathing room look "not actively bad" but not great. Starting with excess ensures adequate whitespace in the final design.

2. Avoid Ambiguous Spacing

Ensure there is more space around the entire group than within the group.

Example - Form Labels:

3. Don't Fill The Whole Screen

Just because you have 1200-1400px of canvas doesn't mean content should stretch to fill it.

4. Whitespace > Borders

Instead of using borders to separate elements:

Visual/UX Signals Used

  1. Proximity: Closer elements = related
  2. Ambiguity gap: More space around groups than within
  3. Breathing room: Generous space = cleaner, more polished
  4. Canvas utilization: Don't stretch to fill; use what you need

Common Failure Modes

| Failure | Description | Fix |

|---------|-------------|-----|

| Arbitrary Values | 15px here, 17px there | Use systematic scale exclusively |

| Weak Grouping | Equal spacing within and between groups | Make between-group spacing significantly larger |

| Ambiguous Spacing | Label and input have same margin | Reduce within-group, increase between-groups |

| Border-Dependence | Using borders instead of space | Increase gap, remove border |

| Canvas Filling | Content stretched to 1200px unnecessarily | Use only the space needed; let whitespace fill rest |

| Minimal Breathing Room | Adding just enough space to not look bad | Start with excess, remove until right |

| Inconsistent Padding | Some buttons 8px, others 12px | Pick one scale value, apply everywhere |

Prerequisites

Dependencies

Refactoring UI References

Example Assessment

Input: Form with: Title (margin-bottom: 16px), Label (margin-bottom: 12px), Input (margin-bottom: 12px), next Label (margin-top: 12px)

Evaluation: FAIL - Ambiguous spacing

Recommendation:

Before:

Label A
[Input A]
Label B    <- Ambiguous: belongs to A or B?
[Input B]

After:

Label A
[Input A]

Label B    <- Clearly belongs to B
[Input B]
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.