04 / Illustrated reference / Refactoring UI / 11 November 2026
A practical guide to visual structure
An illustrated working summary of hierarchy, grouping, color, surfaces, responsive layout, and coherent theme personality.
Elegant is a collection of themes for SmallDocs, a Python website generator. This guide selects advice from Refactoring UI for documentation themes. The examples below are original HTML. Page references identify the reviewed edition; the official book site provides public context. The book covers much more than this task, including product workflows, photos, and empty states.
1. Set the main task's priority
Make the main task stand out by reducing emphasis on competing information. Weight, tone and spacing establish hierarchy, the order in which elements attract attention. Hierarchy does not require enormous titles or tiny supporting text. Secondary information should remain readable.
Refactoring UI, pp. 36 to 47, 54 to 59.Reading notebook
A small collection of ideas from twelve chapters.
Updated today
Supporting text size and tone
Updated yesterday / Python / A short example
Updated yesterday / Python / A short example
2. Space related elements as groups
Related elements need less space between them than unrelated groups. A heading should sit closer to the content it introduces. Consistent spacing values make the whole system feel planned. A rigid arithmetic formula does not replace visual judgment.
Refactoring UI, pp. 66 to 74, 96 to 99.Spacing values
These spacing values illustrate the advice. The book does not require this sequence. Use fine steps for small controls and more distinct steps for larger spaces.
Generous outer space can help even when the lines of a paragraph are too far apart. Margins, line spacing, paragraph separation, and section gaps each have a different job.
3. Define color roles
Use a small set of coherent tones for the main information and the levels of supporting information. On colored surfaces, choose supporting text to work with that hue rather than adding a generic pale grey. Confirm contrast in the actual composition, and give meaning a cue besides color.
Refactoring UI, pp. 42 to 44, 142 to 160, 162 to 168.White on a pastel panel can look friendly while becoming hard to read.
Darker text on a pale surface keeps the palette, while the symbol and words carry the meaning.
Choose dark-mode surfaces and text
Main text remains strong. Supporting text can recede without vanishing.
Updated today / Notes on a chapter
Paper, panel, supporting text, accent, main text. Define a role for each tone, then check the foreground/background pairs that actually occur.
The book supports accessible color choices. For the current numeric requirements, use W3C's Web Content Accessibility Guidelines (WCAG) for contrast. Do not use a pale disabled-looking control as a template for enabled actions.
4. Give each kind of content the width it needs
Choose a reading width that suits the text. Paragraphs benefit from a controlled reading width, also called measure. Tables, diagrams and code may need more room. Refactoring UI suggests 45 to 75 characters for paragraphs and allows some wider cases with care.
Refactoring UI, pp. 76 to 81, 114 to 116.A short paragraph can remain comfortable while a larger data display uses more of the available canvas. Different content widths can belong to the same coherent page.
Title Author Year A Room with a View E. M. Forster 1908 Pride and Prejudice Jane Austen 1813
Adjust large and small elements separately
Reduce large display elements more than already-small reading text. Keeping the same size ratios at every screen width where the layout changes can leave a phone with giant headings and tiny code. Line spacing should also respond to text size and measure rather than being uniform everywhere.
Refactoring UI, pp. 92 to 95, 122 to 125.A title fills the phone
The body shrinks to make room for the display.
find_books(library, "room")
A title makes room
The heading becomes quieter while the body remains comfortable.
find_books(library, "room")
5. Separate surfaces
Use the smallest signal that makes a group clear. A border, a background shift, whitespace, or a shadow can each distinguish a group. Use the tool that fits the hierarchy. Flat designs can convey layers; decorative depth does not earn points by itself. Accent borders can add character without filling the whole component with intense color.
Refactoring UI, pp. 190 to 192, 224 to 226, 238 to 241.The group is clear through spacing and a quiet surface. One accent supplies enough emphasis.
Keep decoration behind the hierarchy
The book allows subtle gradients and patterns; they should support the content without interfering with it. A decorative header can carry the personality while long prose has a stable foreground/background relationship.
Refactoring UI, pp. 202 to 206, 228 to 232.A little visual character
The reading surface stays stable. The decorative background belongs to the surrounding frame, not to every line of text.
6. Choose a style that suits the site
Type, color, shape, and language work together to suggest a character. A playful design is not inherently poor design, but it may be wrong for an elegant documentation site. A serif typeface has small strokes at the ends of its letters. A sans serif typeface has no such strokes. Neutral sans, literary serif and a warm dark palette can all be coherent directions.
Folio, Atelier and Nocturne are our three custom themes. The examples below illustrate their literary, studio and evening styles.
Refactoring UI, pp. 20 to 26, 108 to 112.The reading room
Paper, a text serif, and a measured accent make a quiet editorial voice.
A useful system
A clean sans face, careful grouping, and one fine rule can feel precise without feeling generic.
After hours
A dark ink surface and a selective warm accent give the same content another mood.
These original examples echo the intended roles of Folio, Atelier, and Nocturne. They do not reproduce a layout from the book.
Review a theme
- Identify the task that the reader needs to complete. Examples include reading, finding a section, understanding code, and using a control.
- Read the page in grey or with accents mentally removed. Is its hierarchy still clear?
- Check grouping before adding a divider, shadow, or more color.
- Inspect text on every surface, including secondary buttons, messages, captions, and code.
- Review both modes and narrow widths; do not shrink small text to preserve a desktop composition.
- Use a small set of named design settings for space, type, surfaces, and accents. Verify the generated page as well as the list of settings.
The design assessment applies these principles to all 38 themes. The typography assessment supplies a separate, more prescriptive reading score.
Neither guide makes a mathematical ratio a substitute for judgment. The strongest evidence is a readable page, clear relationships, and a consistent response to real content.
Source
Adam Wathan and Steve Schoger, Refactoring UI, official book site. Page ranges above refer to the reviewed 252-page edition. The guidance has been selectively paraphrased for SmallDocs; illustrations, example copy, and this review's score weights are original. No book PDF, page images, or extracts are distributed.
November component color repairs
The 10 November specimens exposed inherited button and navigation fills in Pulse Reading and Litera Reading. Their declared color pairs passed, but the rendered components failed. The 11 November repairs corrected those fills.
The repairs show why declared colors need a check against the rendered components. Test the rendered styles alongside visible words for component states and form labels. Check the code that associates those words and labels with their controls. A brand color does not automatically mean success, danger or a category in chart data.