Yoga Screen Layout — Mobile

Lay out React Native screens at Mas Yoga's phone counter on real Yoga: flex, axes, safe areas. 15 levels, played right in the browser with nothing to install.

What you learn in this game

React Native does not use CSS. Styles are JavaScript objects made with StyleSheet.create, with camelCase names and numbers without units. What lays them out is Yoga, the flexbox engine Meta builds and React Native itself runs: at this counter the real Yoga 3.2.1 runs for both test phones. The two phones on the stand are real screens in points (pt): the small phone 320 × 568, the big phone 430 × 932. The coloured boxes are what Yoga computed, the dashed chalk lines the picture the villager asked for.

A modern phone screen has parts nothing may cover: the status bar, a notch or Dynamic Island at the top, and the home indicator at the bottom. react-native-safe-area-context gives the safe area of the phone in use through useSafeAreaInsets(): on Mr. Yoga's small phone top 20 and bottom 0, on the big one top 59 and bottom 34. The screens before this one already took their top space from those numbers. Now you put it in.