SafeArea
component automatically handles safe area insets when running inside a mini app. It ensures your app’s content doesn’t get obscured by device UI elements like status bars, home indicators, or navigation bars.
When not inside a mini app, the component returns children unchanged without applying any safe area styles.
Usage
Basic usage
Wrap your content withSafeArea
to automatically apply safe area padding when inside a mini app:
Using asChild prop
Use theasChild
prop to merge safe area padding directly into a single child element instead of wrapping it:
CSS custom properties
TheSafeArea
component exposes safe area values as CSS custom properties on the :root
element:
--ock-minikit-safe-area-inset-top
--ock-minikit-safe-area-inset-right
--ock-minikit-safe-area-inset-bottom
--ock-minikit-safe-area-inset-left
Advanced Usage
Complex layout example
Behavior
- Inside mini app: Applies safe area padding and sets CSS custom properties
- Outside mini app: Returns children unchanged with no modifications
- No children: Still sets CSS custom properties if inside mini app, returns
null
- asChild with invalid element: Logs warning and returns children as-is
Props
SafeAreaProps