Safe areas: keep clear of the notch and the home bar

Phones lose bits of their screen to a notch, a Dynamic Island, a status bar and a home indicator. Watch one inbox screen run into them, then fit itself to four kinds of phone, either way up.

Level: BasicWatch: 11 steps · ~1 minuteTurn the phone yourselfRecall: 3 questions · 8 cardsCompare 4 phonesTSX

What you'll take away

  • Explain what a safe area inset is, and why each phone and each way up reports its own
  • Pick SafeAreaView or useSafeAreaInsets(), and let a header's colour reach the edge
  • Spot why a hard-coded 44 / 34 is too small on one iPhone and wastes space on an SE
  • Know why Android 15 and later need insets too, and that the same code handles both

The 1-minute version

Tap a point and the picture below plays that step.

4Compare them all
iPhone with a Dynamic Island<View>
iOS
Android
The app draws its inbox → …
Step 1 / 11 · step by step
59 / 34inset top / bottom (pt)
0 / 0inset left / right
–things covered
–pt wasted

The picture: one big phone standing in the night city, an inbox on its screen and the hardware drawn over it. Behind it stand the iOS and Android halls; when the app asks, the insets travel to the phone as a light. Red bands are the insets, in points; amber is space a hard-coded padding throws away; a red ✗ marks something covered. The iPhone numbers are what those models report; Android's depend on the maker, so the picture uses a common pair.

Step 4 · Every option at once, on one clock

Compare them all: Safe areas

The same screen on four kinds of phone, all switching together: nothing done, then a hard-coded 44 and 34, then the numbers from useSafeAreaInsets(). See which way covers nothing and wastes nothing on every phone.

1/3 · Nothing
iPhone with a Dynamic Island59 / 34 ptcovered 2 wasted 0 pt

Use it when The biggest top inset (59): a hard-coded 44 isn't enough

Skip it when Buttons or text near the top edge without reading the inset

A model: the iPhone insets are what those models report; Android's depend on the maker, and the picture uses a common pair. Press any tile to see it large above, with when it fits.

Which tool, when

ToolDoesUse it for
SafeAreaView (react-native-safe-area-context)pads a box by the insets, the edges you picka screen or a list that just needs to keep clear
useSafeAreaInsets()gives the four numbersa header whose colour reaches the edge, a bottom bar, anything placed by hand
SafeAreaView from react-nativeiOS only, deprecatednothing new
paddingTop: 44one phone's numbernothing: wrong on most phones

Turning the phone

In landscape the Dynamic Island sits at the side: the insets become 59 left and right, 0 on top and about 21 at the bottom. Code that reads every edge needs no change; code that remembered the portrait numbers puts text under the island.

Android too

From Android 15, apps that target SDK 35 or later are drawn edge to edge, under the status bar and the gesture bar, and Android 16 takes away the way to opt out. The same insets and the same code handle it.

In real code

Inbox.tsx
// One provider at the root, then each part takes the inset it needs: the header keeps its colour behind the status
// bar with the top inset as padding inside it, the list clears the sides (landscape), Compose clears the home bar.
import { FlatList, Pressable, StyleSheet, Text, View } from "react-native";
import { SafeAreaProvider, SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";

type Mail = { id: string; from: string; subject: string };

function Header() {
  const insets = useSafeAreaInsets(); // 59 / 34 on a phone with a Dynamic Island, 20 / 0 on an iPhone SE …
  return (
    <View style={[styles.header, { paddingTop: insets.top, paddingLeft: insets.left + 16, paddingRight: insets.right + 16 }]}>
      <Text accessibilityRole="header" style={styles.title}>Inbox</Text>
    </View>
  );
}

function Inbox({ mail }: { mail: Mail[] }) {
  const insets = useSafeAreaInsets();
  return (
    <View style={styles.screen}>
      <Header />
      {/* The list pads left and right only: the header already took the top, Compose takes the bottom. */}
      <SafeAreaView edges={["left", "right"]} style={styles.screen}>
        <FlatList data={mail} keyExtractor={(m) => m.id} renderItem={({ item }) => <Text style={styles.row}>{item.from}: {item.subject}</Text>} />
      </SafeAreaView>
      <View style={{ paddingBottom: Math.max(insets.bottom, 12), paddingLeft: insets.left + 12, paddingRight: insets.right + 12 }}>
        <Pressable accessibilityRole="button" style={styles.compose}><Text style={styles.composeText}>Compose</Text></Pressable>
      </View>
    </View>
  );
}

export default function App() {
  const mail: Mail[] = [{ id: "m1", from: "Mina", subject: "Lunch?" }, { id: "m2", from: "Krit", subject: "The build is green" }];
  return (
    <SafeAreaProvider>
      <Inbox mail={mail} />
    </SafeAreaProvider>
  );
}

const styles = StyleSheet.create({
  screen: { flex: 1 },
  header: { backgroundColor: "#1d5fae", paddingBottom: 12 },
  title: { color: "white", fontSize: 20, fontWeight: "600" },
  row: { paddingHorizontal: 16, paddingVertical: 14 },
  compose: { backgroundColor: "#1d5fae", borderRadius: 12, paddingVertical: 12, alignItems: "center" },
  composeText: { color: "white", fontWeight: "600" },
});
Run: tsc against each library's own published types (react-native and the libraries this file imports); type-checked only, never run on a phoneIt printed: tsc 6.0.3 (strict): no errors against react-native 0.88.1, react-native-safe-area-context 5.11.1 (type-checked only)

SafeAreaProvider once at the root; the header puts the top inset inside its own colour, the list pads only its sides, Compose takes the bottom inset. Type-checked with tsc against the types react-native 0.88 and react-native-safe-area-context publish; no phone ran it.

Common questions

What is the safe area?

The part of the screen nothing covers. The phone tells the app as an inset per edge: how many points the status bar, notch, Dynamic Island or home bar take. Anything to read or press belongs inside.

SafeAreaView or useSafeAreaInsets?

SafeAreaView pads a whole box: easy, but its background moves too. useSafeAreaInsets() gives numbers to place part by part, right for a header whose colour should reach the edge. Mix them: a list can use SafeAreaView for the sides only.

Table: which to use when

Can I use the SafeAreaView that comes with React Native?

Better not: it only ever worked on iOS and it's deprecated. React Native 0.88's own types point you to react-native-safe-area-context instead.

Can't I just use paddingTop: 44?

On some phones. An iPhone with a Dynamic Island says 59, an iPhone SE says 20 at the top and 0 at the bottom, and turning the phone moves them to the sides. A fixed number is too small on some and too big on others.

What changes when the phone turns?

The insets move to the sides: an iPhone with a Dynamic Island reports 59 left and right, 0 on top, about 21 at the bottom. If your code already reads every edge, nothing to change.

Read: turning the phone

Does Android need any of this?

Yes. From Android 15, apps that target SDK 35 or later are drawn edge to edge, and Android 16 takes away the opt-out, so the status bar and gesture bar can cover content. The same code works on both.

Where does SafeAreaProvider go?

Once, around the root of the app; useSafeAreaInsets() on every screen reads from it. No need to nest more of them.

Next lesson

Keyboard avoiding (KeyboardAvoidingView)Level: Basic

The edges are clear now; next, the keyboard: one more thing covering the bottom of the screen, and this one moves.