Skip to main content
Your view renders inside the host’s surface, on its terms: a bounded height to fit and edges to keep clear of device chrome. useViewport reports those constraints so the view can size itself to the space the host actually gives it. It re-renders on every resize, so read the host theme from useUser instead.

Example

The carousel fits its scroll area to the height the host offers and keeps content clear of notches and home indicators.

Returns

useViewport returns the host’s current viewport for the view, as a ViewportState.

maxHeight

The maximum height in pixels the host gives the view. It is undefined when the host does not report a height limit. It updates as the host resizes the view’s container.

safeArea

The pixel insets the view should keep clear of host chrome and device cutouts (notches, rounded corners, home indicators). When the host reports no insets, every side is 0.

useUser

Read the host’s theme, locale, and device capabilities

useRequestSize

Ask the host to resize the view

Design for the Host

Adapt the view to the host’s surface