A phone frame that survives React Native Web
An iPhone 12 is 390 × 844 CSS pixels. On a wide monitor, GameKal’s web preview shows the app at exactly that size, inside a phone with a notch, and a menu above it switches to another device. The frame comes from a small local package called deevicee, and it does one thing: resize one DOM element to a selected phone, and draw the device menu and cutout where the host framework can’t delete them.
By the end of this post you’ll have a way to frame any web build as a phone at its real size, and two rules for making it survive a framework that owns the DOM.
This post covers the sizes, the two rules React Native Web forced, one flexbox trap, and how devices that share a width collapse into one menu row.
Real sizes, no scaling
Every size in the frame is a logical CSS pixel, 1:1 with the device. The library doesn’t scale a phone to fit the window. If the frame is 390 × 844, the app inside it lays out at 390 × 844, which is the point: you see the layout a phone would actually get.
Sizes come from ios-resolution.com, recorded with the date they were fetched, and each device also carries a top content inset so the app’s menu starts below the cutout:
| Device | Frame | Cutout | Top inset |
|---|---|---|---|
| iPhone 12 – 14 | 390 × 844 | wide notch | 30 px |
| iPhone 14 Pro – 16 | 393 × 852 | Dynamic Island | 56 px |
A notch is short, so 30 pixels clears it. A Dynamic Island floats lower, so its phones need 56.
Rule 1: React Native Web rewrites inline sizes
The obvious way to size the frame is inline styles on the element. That doesn’t last: React Native Web rewrites inline styles on every render, and the size snaps back.
So the size lives in a stylesheet, keyed off data attributes the package sets on the target:
[data-deevicee-target][data-deevicee-device="iphone-12"] {
width: 390px !important;
height: 844px !important;
flex-basis: 844px !important; /* height, because this element is a column child */
padding-top: 30px !important;
}
The !important is deliberate, and rare in my CSS. It’s the one way to win against a framework that rewrites inline styles on every render. And if the framework drops the data attributes, the package stamps them again after layout.
Rule 2: React Native Web deletes nodes it doesn’t own
The device menu and the notch are extra DOM. Put them inside the app’s element and React Native Web removes them on the next render, because it owns that tree.
So both are mounted on document.body, outside the app, and positioned over it. The cutout passes touches straight through (pointer-events: none), so the notch never eats a tap meant for the app underneath. Every cutout is solid black, with no border and no shadow, whatever the app’s color scheme.
The flexbox trap
The frame sits in a column flex parent. In a column, the main size is the height, so flex-basis has to be the device’s height. Base it on the width and the frame comes out squat. That’s why the CSS above sets flex-basis: 844px and not 390.
One row per width
Several phones share a screen size. iPhone 12, 13 and 14 are all 390 × 844. Listing them separately gives you three menu rows that do exactly the same thing, so devices that share a frame width collapse into one row: choosing between them wouldn’t resize anything.
What I learned
Looking back, three lessons stand out.
Keep the frame out of the framework. Anything the framework owns, it can rewrite or delete. Styles in a stylesheet and chrome on document.body survive both.
Use real sizes, and write down where they came from. A preview at the device’s logical size shows the layout a phone will actually get, and the source with its date makes the numbers checkable.
Collapse choices that do nothing. A menu row that doesn’t change the result is noise.
What’s next?
The frame made the web preview honest. The next job was the release catalog behind it: real games, on real days, loaded fast enough that the frame isn’t waiting on it.
390 × 844, at real size, in a frame the framework can’t touch.