Design / Vibe coding
A Vibe Coding Field Guide to Better-Looking Interfaces: 10 Typography, Color, and Micro-interaction Rules
The ten design constraints that stop AI-generated interfaces from looking scattered: a fixed type scale, line length, line height, color tokens, contrast, spacing, radii, dark mode, micro-interactions, and prompt parameters you can paste.
The trap with vibe coding (letting an AI coding assistant build your interface) is not that the output is ugly. It is that every element looks fine on its own and the page falls apart as a whole: an 18px heading next to a 17px subheading, a card with 12px corners next to one with 20px, four different shadows. This is a list of the ten constraints that fix that most reliably, each with parameters you can paste straight into a prompt. They are also the ones we use on KNOWHY Design and the KNOWHY navigation site itself.
1. Fix the type scale before writing a single word
Do not pick sizes element by element. Choose a scale (for example 12 / 14 / 16 / 20 / 24 / 32) and allow text to take only those values. Once the scale is fixed, hierarchy follows on its own. In the prompt: “Font sizes may only be 12, 14, 16, 20, 24, or 32. Body is 16, card titles 20, page title 32.”
2. Control line length
Lines that run too long make the eye lose its place on the way back; too short and the text looks choppy. For English, 45 to 75 characters per line reads comfortably. In CSS that means giving the body copy container a max-width (typically 640 to 760 pixels) instead of letting it stretch with the viewport. On wide screens, give the extra room to whitespace or a sidebar, not to text.
3. Tie line height to font size
Body copy between 1.6 and 1.75 reads with the least effort. Headings are large and short, so tighten them to 1.15 to 1.3. The common error is one site-wide line height, which leaves headings loose and paragraphs cramped. Put both ranges in CSS variables and make the assistant reference them.
4. One primary color, one restrained accent
Colors scatter because of hard-coding: #0f6b68 here, #1a8a86 there, two greens that look alike alone and clash together. Define one primary, one accent used only for marks, derive a light and a deep variant of the primary, and write all of it as CSS variables. Every color the assistant writes must reference a variable. The KNOWHY site uses a single primary #0f6b68 on paper #fafaf8, with the accent reserved for a few marks.
5. Pass contrast before you discuss taste
Low-contrast grey text is exquisite on the designer’s retina display and invisible on a phone in daylight. Body text needs at least 4.5:1 contrast and large text 3:1. That is the WCAG AA threshold and also the floor under “polished”. For a quick start, RandomA11y (listed in the navigation site) generates palettes that already meet contrast; narrow from there.
6. Spacing in multiples of 4 and 8
Hand-written 13px, 17px, and 27px gaps are invisible individually and produce “almost aligned” layouts collectively. Fix a spacing scale (4, 8, 12, 16, 24, 32, 44) and let every margin and padding take a value from it. This constraint works especially well on generated code because it turns unlimited choices into a handful.
7. One radius, two shadow levels
Radii and shadows are where “every component is a little different” shows up most. Define one radius token (16px for cards, 10px for buttons, fully rounded for tags) and reuse it; keep only a light and a heavy shadow, and only on elements that genuinely express depth. If you can do without a shadow, do: a border plus a slight background difference is usually enough.
8. Dark mode is not an inversion
Inverting a light theme yields blinding white text on pure black. The right approach: never pure black for the background, use a near-black (the KNOWHY site uses #0e1312); never pure white for text, use a slightly greyed light tone; brighten the primary on dark backgrounds (#0f6b68 becomes #5cc8bd) or it sinks; and since shadows barely read on dark, separate layers with lighter borders instead.
9. Micro-interactions: do exactly three things
More motion reads as cheaper. The only feedback that reliably improves perceived quality is: hover (a slight background or border change, around 170 ms), keyboard focus (a clear :focus-visible ring, which is also an accessibility requirement), and loading state (an explicit state on submit). And always respect prefers-reduced-motion: if the user turned animations off at the OS level, the page should not animate scrolling.
10. Put the constraints in the prompt
“Make a modern card” yields random results. Effective prompts state every parameter above. Borrow the “Say this” format from KNOWHY Design, for example: “Use a Bento layout for the features section: large card 2×2, small cards 1×1, radius 16px, gap 16px.” It names the layout, sizes, radius, and gap in one sentence, leaving the assistant almost no room to misread you.
The UI设计格子 extension from KNOWHY Apps goes one step further: pick a template, adjust parameters, preview, then export the result as a developer prompt plus HTML/CSS to hand to your vibe-coding tool, which removes the back-and-forth of describing the same thing repeatedly.
A checklist for the monitor edge
- Fixed six-step type scale
max-widthon the body copy container- Body line height 1.6–1.75, headings 1.15–1.3
- Every color through a variable; one primary
- Body contrast ≥ 4.5:1
- Spacing only in multiples of 4 / 8
- One radius variable, at most two shadow levels
- No pure black or pure white in dark mode
- Motion limited to hover, focus, and loading; honor reduced motion
- Sizes, radii, and gaps spelled out in the prompt
None of this requires design talent, only discipline. Put it in your project’s instructions file so the assistant reads it every time, and generated interfaces move from “works” to “someone designed this”.