Skip to component content
Layout014 / 155

SafeAreaInset

Add spacing while respecting a device’s safe-area insets.

Example

Header inset: top and both sides.

Action area inset: bottom and both sides.

Source
SafeAreaInset.tsxtsx
import { SafeAreaInset, Surface, Text, VStack } from "@/ohmygui";

export default function Example() {
  return (
    <VStack align="stretch" gap="sm">
      <SafeAreaInset edges={["top", "leading", "trailing"]} spacing="sm">
        <Surface tone="paper" padding="md">
          <Text as="p">Header inset: top and both sides.</Text>
        </Surface>
      </SafeAreaInset>
      <SafeAreaInset edges={["bottom", "leading", "trailing"]} spacing="lg">
        <Surface appearance="outlined" padding="md">
          <Text as="p">Action area inset: bottom and both sides.</Text>
        </Surface>
      </SafeAreaInset>
    </VStack>
  );
}