Responsive Design for AI Coders | SheCodes
Intermediate 10 min read

Responsive Design for AI Coders

Make your website look great on every screen size, from phones to ultrawide monitors.

In this chapter

  • Why your site looks broken on phones and how to fix it
  • What breakpoints are and which ones to use
  • How to describe responsive layouts to your AI tool
  • The mobile-first mindset every AI coder should adopt

Breakpoints

Breakpoints are the screen sizes where your layout adapts. Your website layout can change at these common screen sizes:

Live example
πŸ“±
Small Phones
Up to 640px
πŸ“±
Large Phones
640px and up
πŸ“‹
Tablets
768px and up
πŸ’»
Laptops
1024px and up
πŸ–₯️
Desktops
1280px and up
πŸ–₯️
Ultrawide
1536px and up

Mobile-First Approach

Live example
Design for phones first, then make it look better on bigger screens. This is how professional designers work.
πŸ“± Phone
1 column
πŸ“‹ Tablet
Col 1
Col 2
πŸ’» Desktop
1
2
3

Common Responsive Patterns

Stack β†’ Row Items stack vertically on mobile, sit side-by-side on larger screens.
Mobile
Desktop
Hide on Mobile Hide an element on mobile, show it on tablet and up.
Mobile
Sidebar
Desktop
Sidebar
Show only on Mobile Show element only on mobile, hide on larger screens.
Mobile
Menu ☰
Desktop
Menu ☰
Responsive Text Text gets larger as the screen grows.
Mobile
Aa
Desktop
Aa
Responsive Padding Increase padding on larger screens for better spacing.
Mobile
Desktop
Responsive Grid 1 column on phones, more columns on bigger screens.
Mobile
Desktop
Full β†’ Constrained Width Full width on mobile, centered and constrained on desktop.
Mobile
Desktop
Responsive Spacing Increase gaps between items on larger screens.
Mobile
Desktop

Responsive Navigation

Hamburger Menu Links hidden behind a ☰ icon on mobile. The most common pattern. Opens a dropdown or drawer.
Logo☰
"Create a navbar that collapses into a hamburger menu on mobile."
Bottom Tab Bar Fixed bar at the bottom on mobile (like phone apps). Usually 4-5 icon tabs.
Home
Search
Create
Profile
"Add a mobile bottom tab bar with Home, Search, Create, Profile icons."
Drawer / Sidebar Slides in from the left on mobile. Shows full navigation with icons and labels.
"On mobile, turn the sidebar into a slide-in drawer triggered by a hamburger icon."

How to Test Responsive Design

Browser DevTools Press F12 and toggle the device toolbar (Ctrl+Shift+M) to preview any screen size.
Resize Browser Window Simply drag your browser window narrower or wider to see the layout change in real time.
Real Devices Test on your actual phone and tablet. Nothing beats real device testing.
Responsive Viewer A free browser extension that shows your site in multiple screen sizes at the same time.

Mobile vs Desktop: Side by Side

See how the same content rearranges itself on different screen sizes. On a phone, everything stacks vertically. On desktop, elements spread out.

Live example
Navigation Bar
Phone
MyApp☰
Desktop
MyAppHomeAboutPricingContact
On phones, the navigation links hide behind a hamburger icon (☰). On desktop, all links are visible in a row.
Live example
Card Grid
Phone
Card 1
Card 2
Card 3
Desktop
Card 1
Card 2
Card 3
Cards stack in a single column on phones so they are easy to scroll. On desktop, they sit in a 3-column grid.
Live example
Hero Section
Phone
Image
Button
Desktop
Button
Image
On phones, the image stacks above the text. On desktop, text and image sit side by side in a split layout.

Common Breakpoints

These are the standard screen widths where your layout should adapt. Think of them as "checkpoints" where your design shifts to fit the screen.

Live example
πŸ“±
sm
640px
27%
Phones (landscape)
πŸ“‹
md
768px
15%
Tablets
πŸ’»
lg
1024px
32%
Laptops
πŸ–₯️
xl
1280px
26%
Desktops
Percentages are approximate global usage. The exact numbers vary, but the takeaway is: you need to design for all of these sizes, not just desktop.

Why Mobile-First?

Most visitors will see your site on a phone first. If it looks great on a small screen, it will look even better when there is more room.

The idea is simple:

  1. Start with the phone layout. Everything in a single column, simple and readable.
  2. At the "md" breakpoint (768px), switch to 2 columns where it makes sense.
  3. At the "lg" breakpoint (1024px), expand to 3 or more columns, add sidebars, and use the extra space.
Live example
How this looks in practice
Step 1: Phone
1 column
Step 2: Tablet
2 columns
Step 3: Desktop
3 columns

Responsive Images

Images that are too wide will break your layout on phones. A responsive image shrinks and grows with its container, so it always fits the screen.

Live example
❌Image breaks layout
Image wider than screen β†’
The image is wider than the phone screen, so it overflows and creates a horizontal scrollbar.
βœ…Image fits perfectly
Image scales to fit
The image automatically shrinks to fit the phone screen. No overflow, no scrollbar.

Three rules for responsive images

  1. Max width 100%: Tell the image to never be wider than its container. This one rule prevents most overflow issues.
  2. Keep the aspect ratio: When an image shrinks, it should stay in proportion (no stretching or squishing). Modern browsers do this automatically.
  3. Lazy loading: Tell images below the fold (not visible when the page first loads) to load only when the visitor scrolls to them. This makes your page load faster.

Touch vs Click

Phone users tap with their fingers, not a precise mouse pointer. Designing for touch means making buttons big enough to tap comfortably.

Live example
❌Too small (32px)
Tap
finger
A 32px button is too small. Your finger covers the entire button and you might hit the wrong thing.
βœ…Correct size (44px)
Tap
finger
A 44px button gives your finger enough room. Apple and Google both recommend at least 44px for tap targets.

Key differences between touch and mouse

  • Bigger tap targets: Buttons, links, and form fields need to be at least 44px tall on mobile. Fingers are much bigger than mouse cursors.
  • No hover on touch: Phones don't have a hover state. If important info only appears when you hover, phone users will never see it. Use tap or always-visible alternatives.
  • Swipe gestures: Phone users expect to swipe through image carousels and dismiss things by swiping. If you have a carousel or gallery, make sure it supports swipe.
  • Spacing between links: Put enough space between tappable items so users don't accidentally tap the wrong one.

Testing Your Responsive Design

You built it, now make sure it looks good everywhere. Here is the quickest way to check.

Using Chrome DevTools (free, built into your browser)

  1. Open your site in Google Chrome.
  2. Right-click anywhere on the page and choose "Inspect" (or press F12).
  3. Click the device icon in the top-left of the panel (looks like a phone and tablet). You can also press Ctrl+Shift+M (Windows) or Cmd+Shift+M (Mac).
  4. Pick a device from the dropdown (iPhone, iPad, etc.) or drag the handles to resize freely.
  5. Check each breakpoint: make the screen narrow, then gradually wider, and watch your layout change.
Live example
What to look for
βœ“
Text is readable
No text is tiny or cut off at any size
βœ“
No horizontal scrolling
Nothing overflows the screen width
βœ“
Buttons are tappable
At least 44px tall on mobile
βœ“
Images scale down
No images break out of their container
βœ“
Navigation works
Hamburger menu opens and closes properly
βœ“
Forms are usable
Input fields are full-width on mobile
MAKE A COMPONENT RESPONSIVE

β€œThis component looks good on desktop but breaks on mobile. Make it fully responsive: stack elements vertically on phones, use 2 columns on tablets, and keep the current layout on desktop. Make sure all buttons are at least 44px tall on mobile, images scale properly, and nothing overflows the screen.”

Prompt This

Copy-paste these prompts into your AI tool to apply what you just learned.

MAKE MY PAGE RESPONSIVE

β€œMake my page fully responsive. On mobile, stack everything vertically with full-width sections. On tablet, use a 2-column grid where it makes sense. On desktop, use the full layout with sidebar. Make sure text is readable and buttons are tappable at every size.”

FIX BROKEN MOBILE LAYOUT

β€œMy website looks broken on mobile. Fix the layout so all content is readable, buttons are large enough to tap, images scale down properly, and nothing overflows or gets cut off on small screens.”

ADD RESPONSIVE NAVIGATION

β€œMake my navigation responsive. On desktop, show all links in a horizontal row. On mobile, collapse the links into a hamburger menu that opens a dropdown or slide-in drawer. Add smooth transitions when opening and closing.”

Frequently Asked Questions

What screen sizes should I design for?

Focus on three: mobile (375px), tablet (768px), and desktop (1280px). Tailwind's default breakpoints (sm, md, lg, xl) cover these well. Always design mobile-first: start with the phone layout and add complexity for larger screens.

Why does my site look different on my phone vs my computer?

Phones have smaller screens and different pixel densities. If you haven't added responsive styles, your desktop layout gets squished on mobile. Tell your AI tool to make every component responsive. It will add the right breakpoints automatically.

What does 'mobile-first' mean?

It means you design for phone screens first, then add styles for larger screens. In Tailwind, unprefixed classes apply to all screens, and prefixed classes (sm:, md:, lg:) add styles at larger sizes. This approach ensures your site always works on the smallest screens.