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**.
525
+
526
+
#### Viewport Modes
527
+
528
+
| Mode | Viewport Field | Meaning |
529
+
|------|---------------|---------|
530
+
| Fixed |`height` or `width`| Host controls the size. App should fill the available space. |
531
+
| Flexible |`maxHeight` or `maxWidth`| App controls the size, up to the specified maximum. |
532
+
| Unbounded | Field omitted | App controls the size with no limit. |
533
+
534
+
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.
535
+
536
+
#### App Behavior
537
+
538
+
Apps should check the viewport configuration and apply appropriate CSS:
539
+
540
+
```typescript
541
+
// In the app's initialization
542
+
const viewport =hostContext.viewport;
543
+
544
+
if (viewport) {
545
+
// Handle height
546
+
if ("height"inviewport) {
547
+
// Fixed height: fill the container
548
+
document.body.style.height="100%";
549
+
} elseif (viewport.maxHeight) {
550
+
// 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:
570
+
571
+
```typescript
572
+
// Host listens for size changes from the app
573
+
bridge.onsizechange= ({ width, height }) => {
574
+
// Update iframe to match app's content size
575
+
if (width!=null) {
576
+
iframe.style.width=`${width}px`;
577
+
}
578
+
if (height!=null) {
579
+
iframe.style.height=`${height}px`;
580
+
}
581
+
};
582
+
```
583
+
584
+
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.
585
+
517
586
### Theming
518
587
519
588
Hosts can optionally pass CSS custom properties via `HostContext.styles.variables` for visual cohesion with the host environment.
0 commit comments