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
| Mode | Layout | Requestable |
|---|---|---|
"inline" | Compact panel embedded in the conversation, the default | |
"fullscreen" | The view takes over the host surface | |
"pip" | Picture in picture, floating above the conversation | |
"modal" | Overlay opened through useRequestModal, host-driven |
setDisplayMode
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