Refactoring UI for Developers: One Settings Page at a Time
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.
- Subtract first, add later: When designing a product, don't start by drawing the shell; first design the core interaction module (for example, a flight search form).
- Stay low-fidelity early: Don't obsess over colors, fonts, or shadows at the start. Iterate quickly on functionality using black-and-white wireframes, avoiding wasted time on decorative details.
- Don't over-design: Only design features required for the current version. Don't draw placeholders for features that may not launch for six months.
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:
- Primary content: dark gray (like
#111827, avoid the harsh pure black#000), paired with regular or medium weight. - Secondary content (e.g., dates, metadata): medium gray (like
#4B5563). - Tertiary content (e.g., footer copyright): light gray (like
#9CA3AF).
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
- Primary action: solid, high-contrast button (keep it to 1 per visible screen if possible).
- Secondary action: outlined button or light background button.
- Tertiary action: plain text link style.
- Destructive action: for actions like "Delete," if they aren't the main purpose of the current page, don't let a big red solid button steal the show. Use secondary or tertiary styling first, then show a red warning button in a confirmation dialog after the user clicks.
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
- Optical alignment: When placing a play icon (triangle) inside a circular button, strict mathematical centering on the bounding box looks off to the left; shift it slightly right based on the shape's visual center. When an icon sits next to text, the icon is usually
2px ~ 4pxlarger than the text size (e.g.,16pxtext with20pxicon) for equal visual mass. - Don't stretch elements to fill large screens: When a big screen has little content, just use
max-width: 768pxcentered. Whitespace on both sides looks far more refined than stretching a card the full width. Similarly, set the left sidebar to a fixed width (e.g.,240px) instead of a percentage that scales with the viewport.
4. Font and Typography Details
1. Type scale and line length
- Build a rhythmic type scale: use something like
12, 14, 16, 18, 20, 24, 30, 36, 48, avoiding the linear, low-discrimination12, 13, 14, 15. - Control characters per line: for comfortable reading, aim for 45–75 English characters per line (about 25–40 Chinese characters), which in CSS is roughly
max-width: 65ch. - Line-height inversely proportional to font size: small body text needs larger line-height (
1.5 ~ 1.75) to prevent line confusion; large headings need compact line-height (1.0 ~ 1.25), otherwise two-line headings look loose and disconnected.
2. Font choices and mixing techniques
- Safe bets and weight filtering: when unsure, use the system font stack or Inter. When picking a font, verify it covers the languages needed on the page and includes the actual weights used, like Regular, Medium, and Bold.
- Tabular numerals and primary/secondary distinction: data dashboards and price tables must enable
font-variant-numeric: tabular-numsto prevent digit jumping. When showing a price like$1,299.00, make the currency symbol$and the.00smaller and lighter; the main digits immediately become more readable. - Alignment and widows: long Chinese/English text usually aligns left for easy scanning; values that need vertical comparison in tables align right. When mixing sizes on the same line (like
$99 /month), usealign-items: baseline. For key headings, manually control line breaks to avoid leaving a single orphan word on the last line. - Responsive type: on mobile, body text starts at
16px. People hold phones closer, and16pxprevents iOS Safari from auto-zooming when focusing an input. On narrow screens, shorten or shrink the heading first, then check body text and input readability.
5. Color and Light & Shadow Quality
1. Use HSL to scientifically adjust color scales
- Switch to HSL mode: Hue, Saturation, Lightness best match human color intuition. A practical design system usually needs 8–10 lightness steps per primary color.
- Hue rotation: when tuning light and dark shades of the same color, try making lighter steps slightly warmer (toward yellow) and darker steps slightly cooler (toward blue), then adjust with brand color and actual background for a more translucent feel.
- Add a hint of hue to neutral grays: pure neutral gray can take a touch of blue (cool gray, good for tech and business) or a yellow-brown cast (warm gray, for lifestyle and reading), depending on the page's dominant color.
2. Text on colored backgrounds and status colors
- Pick text color based on the actual background: on dark or colored backgrounds, for secondary text try reducing the opacity of white (like
rgba(255, 255, 255, 0.7)), or use a high-contrast value from the same hue. On a bright yellow button, don't force white text; use a deep brown or dark olive text in the same hue family. - Restrained status colors (alerts/badges): avoid high-saturation pure red or green with white text. Use very light same-hue background + very dark same-hue text + a medium-saturation small icon – eye-catching but not harsh.
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
- Light from above: mimic the real-world top light. Raised elements (buttons, cards) get a very thin bright highlight on top (
inset 0 1px 0) and a drop shadow below; recessed elements (input fields) get an inset top shadow. - Two-layer shadow: use two shadow layers for a natural floating feel. One large, soft diffuse shadow conveys spatial distance, paired with one small, sharp contact shadow simulating the dark area where an object touches the ground. The higher an element's elevation, the larger the vertical offset and blur radius, but the lower the opacity. For a primary brand button, a same-hue semi-transparent colored shadow can enhance transparency.
- Dark mode dimensionality: on dark backgrounds, black shadows are barely visible. Instead of shadows, use surface brightness progression (darkest at the base background, slightly lighter for cards, brightest for modals) plus a 1px faint white translucent top inner highlight to separate levels.
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:
- Is spacing too tight? Try doubling all containers'
paddingand element spacing. - Is all text equally black? Make secondary text medium gray and tertiary text light gray.
- Are there too many borders and dividers? Cut half of the
1pxborders; use background contrast or whitespace instead. - 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.
- Is the page too wide and elements stretched too long? Add
max-widthto 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.