10 Design Tips to Know as a Developer

Small design rules that make your interfaces look and feel better.

There are times when you need to build a screen without a designer, or a mockup leaves out the small details. You don't need to be a designer to make it look good. A handful of simple rules get you most of the way there.

Good design for developers is mostly about consistency: pick a small set of values and stick to them.

Most of these come from years of building UIs and from the book Refactoring UI, which I recommend to every front-end developer.

1. Use a spacing scale

Random margins like 13px and 22px make a layout feel off even when you can't say why. Pick a scale based on 4px or 8px and only use values from it.

:root {
--space-1: 4px;
--space-2: 8px;
--space-3: 12px;
--space-4: 16px;
--space-6: 24px;
--space-8: 32px;
--space-12: 48px;
--space-16: 64px;
}
.card {
padding: var(--space-6);
margin-bottom: var(--space-8);
}

Now when you're deciding between two values the choice is easy. Try one step up or one step down.

2. Limit your font sizes with a type scale

The same goes for text. Six or seven font sizes is usually plenty for a whole app. clamp() lets the larger sizes grow with the viewport without media queries.

:root {
--text-sm: 0.875rem;
--text-base: 1rem;
--text-lg: 1.25rem;
--text-xl: 1.5rem;
--text-2xl: 2rem;
--text-3xl: clamp(2rem, 5vw, 3rem);
}

3. Watch line height and line length

Long lines of text are hard to read because your eye loses its place going back to the start of the next line. Keep paragraphs to around 45–75 characters wide. The ch unit makes this simple.

p {
max-width: 65ch;
line-height: 1.6;
}
h1,
h2 {
line-height: 1.2;
}

Body text needs a taller line height than headings. Big text with a big line height looks disconnected.

4. Check your contrast

Light grey text on a white background looks clean in a mockup and is unreadable for a lot of people. The WCAG AA guideline is a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text.

/* Fails AA on white (about 2.3:1) */
.muted {
color: #aaaaaa;
}
/* Passes AA on white (about 4.5:1) */
.muted {
color: #767676;
}

Chrome DevTools shows the contrast ratio when you inspect a color in the styles panel, so there's no excuse to guess.

5. Use fewer colors and tint your greys

You don't need ten brand colors. One primary color, a set of greys and a few state colors (success, warning, error) will cover most apps. Give each a few shades so you have something for backgrounds, borders and text.

Pure greys can look flat. Tinting them slightly toward your primary color makes the whole palette feel like it belongs together.

:root {
--primary-600: #1d4ed8;
--primary-500: #2563eb;
--primary-100: #dbeafe;
/* greys with a little blue in them */
--grey-900: #1e293b;
--grey-600: #475569;
--grey-300: #cbd5e1;
--grey-100: #f1f5f9;
--error: #dc2626;
--success: #16a34a;
}

6. Build hierarchy with weight and color, not just size

When something needs to stand out the first instinct is to make it bigger. Often it's better to make the less important things quieter instead. A bolder weight or a darker color does a lot without blowing up the layout.

.price {
font-size: var(--text-lg);
font-weight: 700;
color: var(--grey-900);
}
.price-label {
font-size: var(--text-sm);
font-weight: 400;
color: var(--grey-600);
}

7. Keep border radius and shadows consistent

Buttons with 4px corners next to cards with 12px corners next to inputs with 2px corners look accidental. Pick a couple of radius values and a small set of shadows, from subtle to raised, and reuse them.

:root {
--radius-sm: 4px;
--radius-md: 8px;
--shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.08);
--shadow-md: 0 4px 12px rgba(15, 23, 42, 0.12);
}
.card {
border-radius: var(--radius-md);
box-shadow: var(--shadow-sm);
}

8. Align everything to something

Every element should line up with something else on the page. Text that starts a few pixels off from the heading above it, or an icon that sits slightly too low, is the kind of thing people notice without knowing why. Flexbox with gap makes consistent alignment and spacing much easier than margins on every child.

.toolbar {
display: flex;
align-items: center;
gap: var(--space-3);
}

9. Give things more whitespace than you think

Developers tend to pack things in tight. Start with too much space and remove it until it looks right, rather than the other way around. Space between groups should be larger than space within a group so related items read as one unit.

.form-field {
margin-bottom: var(--space-6);
}
.form-field label {
display: block;
margin-bottom: var(--space-2);
}

10. Design every state

A mockup usually shows the happy path. Real users will hover, tab with a keyboard, wait for data, and land on a page with nothing in it. Plan for:

  • Hover and active
  • Focus (visible for keyboard users)
  • Disabled
  • Loading
  • Empty and error
.button:hover {
background: var(--primary-600);
}
.button:focus-visible {
outline: 3px solid var(--primary-500);
outline-offset: 2px;
}
.button:disabled {
opacity: 0.5;
cursor: not-allowed;
}

:focus-visible shows the focus ring for keyboard users without showing it on every mouse click, so there's no reason to remove outlines anymore. For empty states, a short message and a clear next action ("No projects yet. Create your first one.") goes a long way.

None of these need a design degree. Pick your scales, put them in CSS custom properties and stick to them, and your UI will look a lot more intentional.

Have some feedback on this post? .