useSafeArea() reads both regions so your layout can pad around them. It imports
from @mentra/miniapp/react, the UI layer
of the two-layer architecture.
useSafeArea()
Returns an object with two fields.
insets always has all four sides, defaulting to 0 when the host provides none
(for example, a browser preview):
capsuleMenu is the rect of the floating control in the top-right. Use it to keep
interactive elements out from under the menu, since taps there reach the host.
Coordinates are in CSS pixels. Always handle
capsuleMenu === null so your layout
still works outside the Mentra App and on hosts that don’t draw a menu.useCapsuleHeaderStyle()
When you want your own header markup but want the capsule alignment done for you,
useCapsuleHeaderStyle() returns a CSSProperties object you spread onto your
header element. It positions the row vertically centered on the capsule menu and
reserves room on the right so your content doesn’t slide under it.
The returned style sets
display: flex with justifyContent: "space-between", so
a left child and a right child split to opposite ends of the row.
<MiniappHeader>
For a stock header, <MiniappHeader> renders the aligned row for you. It has three
slots (left, title, right) and respects the safe area and capsule menu the
same way. It also accepts every useCapsuleHeaderStyle() option as a prop. Render
it inside a root that is already padded by insets, as in the first example.
<MiniappHeader> also forwards leftPadding, rightGap, fallbackHeight, and
fallbackMarginTop through to the underlying useCapsuleHeaderStyle(). The
component ships only the layout, so use className or style for colors and fonts.
Status bar and home indicator colors
The WebView fills the whole screen, so the Mentra App draws no bars of its own. Whatever your page paints at its top and bottom edges shows behind the status bar and the home indicator.- Put your background (a color, gradient or image) on the root element you pad with
insets, and make that element fill the screen. Padding, unlike margin, keeps the background under the status bar and the home indicator. - The status-bar text follows the Mentra App’s light or dark theme. Wrap your app in
<MentraProvider>, which mirrors that theme as<html class="dark">, and define colors for both themes so the status bar stays readable.
Next steps
React webviews
The UI layer overview and its hooks.
Two-layer architecture
How the UI and background layers split and talk.

