Skip to main content
A host renders the view in one of a few layouts: a compact inline panel, fullscreen, or a floating picture-in-picture. useDisplayMode lets the view read which layout it is in and ask the host to switch to another.

Example

The product carousel shows more columns when it takes the full screen. From the inline panel it offers a “See all” button to expand, and once expanded, a “Collapse” button to shrink back.

Returns

useDisplayMode returns a tuple: the current mode first, the setter second.

displayMode

The mode the host is currently rendering the view in. It updates on its own when the host changes the layout (the user expanding or collapsing the view, for instance), so a component can render against it directly.

setDisplayMode

Asks the host to switch the view to mode. The host decides: it can grant the request, keep the current mode, or coerce to another. The promise resolves with the mode actually applied, so read the resolved value rather than assuming the request took. mode the mode to request, every DisplayMode except "modal":
On mobile, ChatGPT coerces a "pip" request to "fullscreen".

Design for the Host

Adapt the view to display mode, theme, and device

useLayout

Read the space and insets a mode switch brings

useRequestModal

Open the view as a host modal