All articles

Mobile10 min read

The iPad is a phone too: what breaks on a tablet

My React Native app ran on the iPad, but it wasn't designed for it. What broke on the tablet, the layout rules that fixed it and how I check every screen.

Also in Português, Español, Français

One of my apps has always run on the iPad. The supportsTablet: true setting was there from the start, and the app shipped as universal, without the black bars of a stretched iPhone app. And that's exactly why I never really looked: if it opens, it works, right?

In September I opened the app on the iPad Pro 11" simulator and went through it screen by screen. The summary of my notes from that day: the app runs natively on the iPad, but it wasn't designed for it. Everything full screen just stretched the phone layout.

This post is what I found, the rules I adopted and how I've checked every new screen since then.

TL;DR#

  • What breaks on a tablet is almost always width: an 800 pt button, a 780 pt line of text, a percentage grid with crooked margins.
  • Decide by window width, never by device model. An iPad in Split View is as narrow as a phone.
  • Content stops stretching at 760 pt and centers. Forms stop at 480 pt.
  • The grid calculates how many columns fit, no width: "48%".
  • Scenes with drawn art: everything scales together, from a single coordinate system.
  • And the rule that ties it all together: no screen is done without the iPad screenshot.

What I saw on the iPad#

Some of my notes from that day, on the iPad Pro 11" in portrait (834 × 1210 pt):

  • Login: fields and buttons from edge to edge. It looked like a broken form.
  • Main buttons: about 800 pt wide.
  • Reading screens: lines of text about 780 pt long. Running text that long is tiring; the comfortable range is close to 600.
  • Grids: two giant columns and the right margin bigger than the left.
  • Framed screens: a 440 pt device frame, used on some screens, squeezed the content into the middle of the tablet.
  • Text: the same 14 pt as on the phone, far from your eyes, in the middle of an 11-inch screen.

And one thing was good: the dialogs. They already had a max width and stayed centered. That was the clue for fixing the rest.

Why the margin was crooked#

This one deserves a paragraph, because it shows up in almost every app. The grids looked like this:

<View style={{ flexDirection: "row", flexWrap: "wrap", justifyContent: "space-between" }}>
  {items.map((item) => <Card key={item.id} style={{ width: "48%" }} />)}
</View>

Two 48% cards add up to 96%. On the iPhone, the leftover 4% is 1 or 2 pt and nobody notices. On the iPad, it's about 40 pt, and depending on the alignment it all lands on one side. Percentages hide the leftover on the phone and show it on the tablet.

Rule 1: the window decides, not the device#

The temptation is to ask "is it an iPad?". But what matters is the space the app has:

  • An iPad in Split View is as narrow as a phone.
  • A phone in landscape is wide, but short, and it doesn't become a tablet.

So I created a ruler, based on window width:

layout.ts
export type WidthClass = "compact" | "medium" | "wide";
 
// Where the class changes. "medium" is a tablet in portrait, "wide" in landscape.
export const CLASS_LIMIT = { medium: 600, wide: 900 } as const;
 
export function widthClass(width: number): WidthClass {
  if (width >= CLASS_LIMIT.wide) return "wide";
  if (width >= CLASS_LIMIT.medium) return "medium";
  return "compact";
}
 
export function useLayout() {
  const { width } = useWindowDimensions();
  const cls = widthClass(width);
  return { width, cls, isTablet: cls !== "compact" };
}

useWindowDimensions changes when the window changes (it rotates, it enters Split View), so the screen follows along without any extra code.

Rule 2: content has a ceiling#

Above a certain width, content stops stretching and centers. I picked 760 pt: it fits a grid of 4 and running text is still readable. Forms and intro text are narrower, 480 pt.

export const MAX_CONTENT_WIDTH = 760;
export const MAX_FORM_WIDTH = 480;
 
// Ready to spread into a style: stretches up to the ceiling and centers.
// On a phone the window is narrower than the ceiling and nothing changes.
export const CONTENT_COLUMN = { width: "100%", maxWidth: MAX_CONTENT_WIDTH, alignSelf: "center" } as const;
export const FORM_COLUMN = { width: "100%", maxWidth: MAX_FORM_WIDTH, alignSelf: "center" } as const;

The detail I like most: on the phone this changes nothing. The window is already narrower than the ceiling. There's no if (isTablet) scattered across the screens, and the risk of breaking the iPhone while fixing the iPad is almost zero.

For screens that paint the background from edge to edge (the colored header, a list scrolling across the whole window), instead of the ceiling I calculate an extra margin to center only the content.

Rule 3: the grid counts columns#

Instead of percentages, the grid asks how many columns fit without the card getting narrower than a minimum:

export function gridColumns(args: {
  width: number;
  minCellWidth: number;
  gap: number;
  min?: number;
  max?: number;
}): number {
  const { width, minCellWidth, gap, min = 1, max = 6 } = args;
  const fits = Math.floor((width + gap) / (minCellWidth + gap));
  return Math.max(min, Math.min(max, fits));
}
 
// Exact cell width: split what is left after the gaps, no percentages.
export function cellWidth(width: number, columns: number, gap: number): number {
  return Math.floor((width - gap * (columns - 1)) / columns);
}
  • min keeps the phone grid looking the way it always has.
  • max prevents seven buttons side by side, which nobody can read.
  • cellWidth splits exactly what's left, so the margins are the same on both sides.
The same grid: two columns on the iPhone and four on the iPad, with no tablet if on the screen

Rule 4: iPad in portrait only#

Here I had to make a choice. With orientation: "portrait" in app.config, I thought the app stayed in portrait on any device. On the iPhone, it did. On the iPad, Expo added all four orientations to Info.plist, because Apple requires that from apps that support Split View. And the app rotated to landscape, with layouts that had never been tested that way.

To stay in portrait only on the iPad, the app has to opt out of Split View:

app.config.ts
ios: {
  supportsTablet: true,
  // Opting out of Split View is what lets Apple accept portrait only on iPad.
  requireFullScreen: true,
  infoPlist: {
    // Explicit, not inherited from `orientation`: the Expo plugin does not
    // remove this key from an older prebuild, and it would keep all four
    // orientations until someone ran `prebuild --clean`.
    "UISupportedInterfaceOrientations~ipad": [
      "UIInterfaceOrientationPortrait",
      "UIInterfaceOrientationPortraitUpsideDown",
    ],
  },
},

It's a trade-off, not a fix. Anyone who uses the iPad with two apps side by side can't do that with this app. For an app people use with their full attention, I thought it was worth it. For a note-taking app, I'd decide the opposite.

Rule 5: text grows on its own#

On a phone, the screen is a hand's width from your face. On an iPad, it's farther away and the same text reads small. So anyone who never picked a font size gets the largest size on the tablet:

export function defaultFontLevel(chosen: FontLevel | null, win: { width: number; height: number }): FontLevel {
  // Whoever picked a size in Settings keeps it, on any device.
  if (chosen) return chosen;
  // Shorter side: a phone in landscape is not a tablet, and a narrow Split View keeps phone text.
  const shorterSide = Math.min(win.width, win.height);
  return widthClass(shorterSide) === "compact" ? "default" : "xlarge";
}

Rule 6: art and scene scale together#

The app has a few interactive scenes with drawn art, and they were designed in phone points. And on the iPad the worst kind of bug showed up: the one that works, but looks ugly.

In one of them, the background art was stretched to fill the screen, but the image came out at its natural size (1 point per pixel). The target ended up at the bottom and cut off, and the elements people tap were out of place, far from the drawing.

The fix was to have a single coordinate system, in the art's pixels: the reference points measured in the file itself, and the background drawn with an explicit width and height at that scale. Every element in the scene uses the same coordinates, so there's no way for one to drift away from another.

For the stages of these scenes, a function decides how much the drawing can grow:

// How much a drawing of size `base` can grow to fit `available` without
// distortion: the smaller slack, never below 1 (the phone stays as designed)
// and never above `max`.
export function scaleToFit(available: Size, base: Size, max = 2.4): number {
  if (!(available.width > 0) || !(available.height > 0)) return 1;
  const fits = Math.min(available.width / base.width, available.height / base.height);
  return Math.min(max, Math.max(1, fits));
}

The stage grows, and the elements grow with it, in the same proportion. Never below 1, so the phone stays as designed, and never above 2.4, so nobody sees the drawing's pixels.

How I check every screen#

After that, I made it the rule: no screen is done without the iPad screenshot, next to the iPhone screenshot. In practice:

  • One fixed iPad simulator, the iPad Pro 11". It's wide enough to break a phone layout and narrow enough to make it look like everything is fine.
  • A test account just for the tablet, with data far enough along for every screen to show up.
  • Geometry tests for the scenes, on a small iPhone, a large one and a tablet. Whatever I can prove with math, I prove in Jest.

Two simulator tips that saved me time:

You don't need to rebuild for the iPad. If the app on the iPad simulator is outdated, you can copy the iPhone one, which supports iPad and keeps the login:

xcrun simctl install <ipad-udid> "$(xcrun simctl get_app_container <iphone-udid> com.example.app app)"

Shut down the iPad when you're done. Two simulators running squeeze the memory of any machine.

What the screenshot caught#

For this post, I opened one of the app's store screens on both simulators, and the first card on the iPad had a title broken in the middle of the word. I recreated the problem here with a sample store:

Four columns plus the larger tablet text: the long word breaks in the middle

"Personalizaçã" on one line and "o" on the next (Personalização is the Portuguese word for “customization”). Each rule on its own is right: four columns fit, and larger text reads better. Together, they make the card too narrow for a long word. I haven't fixed it yet. The way I see it, I can give the title a minimum width per column (the grid's minCellWidth) that fits the longest word at the tablet text size, or let the title shrink a little before it breaks. It's exactly the kind of thing that only shows up when you look at the screen.

What I learned#

"Runs on the iPad" is not "works on the iPad". The app never threw an error on the tablet. It just looked sloppy.

A width ceiling solves more than a breakpoint. A maxWidth with alignSelf: "center" fixed more screens than any if (isTablet) would have, and with no risk to the phone.

Percentages hide the leftover. Calculating columns and exact widths keeps the grid honest at any size.

Correct rules collide too. A grid that grows and a font that grows, each one making sense, broke a word. That's why the iPad screenshot is part of every delivery.

Checklist#

  • Open the app on a real iPad (or the simulator) and go through every screen.
  • Decide layout by window width, never by model.
  • maxWidth on content (about 760) and on forms (about 480), centered.
  • Replace percentage grids with a calculated number of columns.
  • Decide the iPad orientations on purpose, knowing that portrait only requires opting out of Split View.
  • Art and interactive scenes on a single coordinate system, with a minimum and maximum scale.
  • iPhone and iPad screenshots before saying it's done.

References#

  • Mobile
  • react-native
  • ipad
  • ios
  • layout
  • expo

Written by

Software engineer and designer. I write about what I run into while building apps, APIs and products.