You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `viewport` field in `HostContext` communicates sizing constraints between host and app. Each dimension (height and width) operates independently and can be either **fixed** or **flexible**.
533
+
534
+
#### Viewport Modes
535
+
536
+
| Mode | Viewport Field | Meaning |
537
+
|------|---------------|---------|
538
+
| Fixed |`height` or `width`| Host controls the size. App should fill the available space. |
539
+
| Flexible |`maxHeight` or `maxWidth`| App controls the size, up to the specified maximum. |
540
+
| Unbounded | Field omitted | App controls the size with no limit. |
541
+
542
+
These modes can be combined independently. For example, a host might specify a fixed width but flexible height, allowing the app to grow vertically based on content.
543
+
544
+
#### App Behavior
545
+
546
+
Apps should check the viewport configuration and apply appropriate CSS:
547
+
548
+
```typescript
549
+
// In the app's initialization
550
+
const viewport =hostContext.viewport;
551
+
552
+
if (viewport) {
553
+
// Handle height
554
+
if ("height"inviewport) {
555
+
// Fixed height: fill the container
556
+
document.body.style.height="100%";
557
+
} elseif (viewport.maxHeight) {
558
+
// Flexible with max: let content determine size, up to max
When using flexible dimensions (no fixed `height` or `width`), hosts MUST listen for `ui/notifications/size-changed` notifications from the app and update the iframe dimensions accordingly:
578
+
579
+
```typescript
580
+
// Host listens for size changes from the app
581
+
bridge.onsizechange= ({ width, height }) => {
582
+
// Update iframe to match app's content size
583
+
if (width!=null) {
584
+
iframe.style.width=`${width}px`;
585
+
}
586
+
if (height!=null) {
587
+
iframe.style.height=`${height}px`;
588
+
}
589
+
};
590
+
```
591
+
592
+
Apps using the SDK automatically send size-changed notifications via ResizeObserver when `autoResize` is enabled (the default). The notifications are debounced and only sent when dimensions actually change.
593
+
525
594
### Theming
526
595
527
596
Hosts can optionally pass CSS custom properties via `HostContext.styles.variables` for visual cohesion with the host environment.
0 commit comments