跪拜 Guibai
← Back to the summary

Refactoring UI for Developers: One Settings Page at a Time

写给开发者的-重构-ui-实战笔记-从改好一个设置页开始-告别-程序员审美-cover.png

Open your own account settings page. The form fields work, saving works, but a quick glance tells you the page feels cramped, and you have to hunt for the "Save" button. What does it take to make your app or site look more professional and comfortable?

You don't need to rebuild from scratch. Start by fine-tuning this one page: make the title stand out more than the description, bring input fields that belong to the same group closer together, and increase the visual weight of the "Save" button. After those changes, glance again. If you can more quickly grasp what the page is about and where to click next, the whole interface already feels cleaner. That's exactly where Refactoring UI is most useful for developers. Most of the advice in the book can begin with such immediate, small changes.

The two authors of Refactoring UI have collaborated on many side projects. Full-stack developer Adam Wathan builds the functionality, while designer Steve Schoger polishes the interface. Over years of working together, they accumulated a large set of practical, directly applicable tweaks, which they shared through short posts, blog posts, and videos, eventually organizing them into this book. The visual hierarchy, whitespace, and border decisions it discusses can be validated in any current project. The authors describe the book's origin on their website

Currently, the Essentials package on the Refactoring UI website is priced at $99 (local taxes extra), including a 218-page PDF ebook and 3 video tutorials; the complete package costs $149 and additionally includes component examples, color schemes, and other resources. Official pricing

If you're still hesitating whether to spend $99 on the book, try applying the methods compiled below to a page you're working on. For instance, increase the spacing between form fields, drop the styling of secondary buttons a step, and see whether the grouping and primary action become immediately clearer. Try those changes yourself before deciding if you need the full cases and video demonstrations in the book.

To see what other developers think of this book, check out the "Hacker Bookshelf" I built. I've collected Hacker News community discussions and recommendations about Refactoring UI on the book page; if you have no design background and often independently handle forms, admin pages, or personal projects, start with the recommendations there to see which interface problems it actually solves. View Refactoring UI on the Hacker Bookshelf

Below, we systematically work through the book's core ideas: starting from function, visual hierarchy, spacing and layout, typography, color and light, and refactoring common components. At the end there's a five-minute page-check checklist you can directly use.

1. Start Designing from the Core Function

1. Start from function, not from layout

Many people rush to draw the nav bar, sidebar, and footer at the very beginning of a design. The page skeleton gets locked in, but the actual core function can't fit or feels cramped.

2. Test the interface with real data and edge cases

Once the layout is roughly set, replace placeholder text like Lorem Ipsum or John Doe with real business content as soon as possible. Fake data is often uniform in length and lacks outliers; the real world has usernames with 40 characters, missing avatars, and posts with zero comments. Only by filling the interface with real, even extreme, samples can you expose problems like broken wrapping or buttons squeezed out of shape early.

同宽卡片换成长标题后按钮溢出,允许标题换行可为按钮保留空间

2. Use Visual Hierarchy to Emphasize What Matters

If every element on a page is "shouting," then the result is no emphasis. Good interface design guides the eye through clear visual hierarchy.

1. Don't rely only on font size to differentiate levels

A common novice mistake is making the title 32px and body text 16px, only to find the hierarchy still unclear. To pull apart the levels, combine size + weight + color contrast:

Core tip: Emphasize primary elements by de-emphasizing secondary ones. When a title isn't prominent enough, instead of making it bigger, try making the adjacent body text lighter.

2. Often, labels are unnecessary

When displaying data, there's no need to write Name: Zhang San, Email: [email protected], Phone: 13800138000. The eye immediately recognizes an email address and phone number; showing the data directly is cleaner. If the business context truly requires labels (like a configuration parameter list), emphasize the value, de-emphasize the label.

3. Strictly differentiate button visual weights

同一设置页的两种按钮样式,右图突出保存并降低取消的视觉权重

3. Establish Layout and Spacing Rules

1. Start with generous whitespace, then reduce

Developers tend to fill pages and add margin incrementally. Try the opposite: start with a noticeably larger whitespace, then pull back until it feels visually comfortable.

2. Establish a fixed spacing and size scale

Don't write 13px, 17px, 22px arbitrarily in CSS. Build a system with obvious gradients (e.g., 4, 8, 12, 16, 24, 32, 48, 64, 96, 128) so adjacent steps have visible gaps, making before/after comparisons easy.

3. Use intra-group and inter-group spacing to express ownership

If in a form the distance from Label to Input is 8px, and the distance from one field group to the next is 12px, everything sticks together in a mess. Start with intra-group 8px, inter-group 24px so labels visually sit with their inputs.

右图缩短标签与输入框的距离,并拉开字段组之间的间距

4. Optical alignment beats mathematical centering, and control max width

4. Font and Typography Details

1. Type scale and line length

相同容器和字号下,右图限制正文栏宽,让每行文字更短

2. Font choices and mixing techniques

5. Color and Light & Shadow Quality

1. Use HSL to scientifically adjust color scales

2. Text on colored backgrounds and status colors

When checking ordinary text color combinations, refer to the WCAG 2.2 AA text contrast requirement, usually at least 4.5:1. If using semi-transparent text, measure the final contrast against the actual background it sits on.

同一条失败提示的配色对比,右图用浅红底、深红文字和清楚的状态名称

3. Simulate real light sources and the two-layer shadow method

6. Practical Fixes for Common Components

Component / Scenario Common Problem Suggested Fix
Borders and dividers Adding 1px solid #ddd to every card and list item Use fewer borders! Replace with soft shadows, subtle background differences (gray base, white card), or larger spacing
Image handling Text over an image with a full semi-transparent black overlay; white-background images blend into white backgrounds Use a partial gradient overlay only on the text side; add a very light inner border on the image inset 0 0 0 1px rgba(0,0,0,0.08)
Form layout For space, use two or three columns; use Placeholder instead of Label Single column vertical layout gives the smoothest reading flow; keep visible Labels, use Placeholder only for examples; validate on onBlur
Login/Register page Including a "Confirm password" field; third-party login as colorful large buttons Use a single password field with a clearly labeled show-password button; make third-party login white background, light gray outline buttons
Table Full of vertical lines; header heavy and bold; every row has a full set of action buttons Remove vertical lines that don't aid reading; reduce header weight while keeping clarity; stack related columns vertically; move infrequent actions into a ... menu; clearly distinguish zero from missing values
Data charts Using pie charts when there are many categories and precise size comparison needed Use horizontal bar charts instead; long labels are easier to lay out and proportions are clear at a glance
Interaction hit area Small close icon (16×16px) directly bound to click events Keep the visual small, expand the actual click area to 40 × 40 CSS pixels via transparent padding
Cards and tags Buttons on side-by-side cards misalign when text lengths differ; small icons enlarged as illustrations Use flex: 1 to force the bottom action bar to align horizontally; when enlarging a small icon, put it in a light circular container; badges use pill rounded corners
Empty and loading states Empty page says only "No data"; loading only shows a spinner Give the empty page a simple illustration, guiding copy, and an action button; use skeleton screens for loading to reduce layout shift

右图减少竖向分割线,并将金额右对齐以便比较

7. Five-Minute Page Check Checklist

When you finish a page and feel "something's off but can't say what," go through these 5 steps:

  1. Is spacing too tight? Try doubling all containers' padding and element spacing.
  2. Is all text equally black? Make secondary text medium gray and tertiary text light gray.
  3. Are there too many borders and dividers? Cut half of the 1px borders; use background contrast or whitespace instead.
  4. Are there too many prominent buttons? Ensure only 1 solid primary button is on the current screen; demote the rest to outlined or text buttons.
  5. Is the page too wide and elements stretched too long? Add max-width to the main container and center it, then check both wide and narrow screens.

Extended practice suggestions

To internalize these rules into design intuition, don't aimlessly browse concept designs detached from real business. Pick a few established products with restrained, comfortable interfaces (like Stripe, Linear, GitHub), open the browser DevTools, and measure their font sizes, line-heights, spacing, and shadow parameters like you're deconstructing code. Even replicate a single page pixel-perfect. Copy a small component by hand, then compare spacing, line-height, and button weight item by item. The feel builds quickly.