Overview
TheSafeArea component wraps content with device safe area padding and viewport dimension constraints. It replaces the common pattern of manually combining useSafeArea() and useViewport() in every resource.
Wraps onhostcontextchanged
MCP Apps SDK reference
Import
Props
SafeArea accepts all standard <div> props (className, style, ref, etc.) plus:
Content to render inside the safe area.
Usage
What it does
SafeArea renders a <div> with:
paddingTop,paddingBottom,paddingLeft,paddingRightfrom the host’s safe area insets in pixels (for notches, status bars, rounded corners)height,maxHeight,width,maxWidthfrom the host’s container dimensions in pixels (whichever the host provides)- In fullscreen mode,
height: 100dvhis applied automatically (unless the host provides an explicit height), so flex column layouts with internal scrolling work without manual display mode handling
style prop. Any additional props (like className) are passed through to the underlying <div>.
Ref forwarding
SafeArea forwards refs to the underlying <div>, so you can use it with useRef: