Safe areas

Use the current screen’s insets to keep content clear of system bars and display cutouts.

NitroUI draws edge-to-edge by default on Android, including versions before Android 15. Use safe-area insets to keep interactive content clear of system bars and display cutouts.

Call useSafeAreaInsets() inside an iOS or Android screen. It returns top, right, bottom, and left in points and updates when the screen’s safe area changes. This header keeps its background all the way to the top edge while placing its title below the inset.

import { Text, View, useSafeAreaInsets } from 'nitro-ui-renderer'

export function Header() {
  const insets = useSafeAreaInsets()
  return (
    <View
      layout={{
        paddingTop: insets.top + 8,
        paddingLeft: insets.left + 16,
        paddingRight: insets.right + 16,
        paddingBottom: 8,
      }}
      style={{ background: 0xe4efdcff }}
    >
      <Text fontSize={22}>Notebook</Text>
    </View>
  )
}

A navigation screen gets the insets for its own controller. Read them where you lay out that screen so its padding follows changes in the available space.

Add the keyboard inset to the bottom safe-area inset when your screen needs to make room for the software keyboard. useKeyboardInset

Pad scrolling content

For a ScrollView, put the inset on ScrollViewContent so it scrolls with the content. When you supply the insets yourself, set contentInsetAdjustmentBehavior="never" on iOS to avoid doubling the padding. For a List, add the inset to the corresponding edge of contentPadding. ScrollView example · List props

On this page