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.
<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.
Next steps
React webviews
The UI layer overview and its hooks.
Two-layer architecture
How the UI and background layers split and talk.

