> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# LynxViewport

The page's size and the app window's, as signals that follow a phone folding or unfolding, a rotation and split screen. `import { LynxViewport } from '@blotch/angular-lynx';`

## Usage

```typescript title="src/app/inbox.ts"
import { Component, computed, inject } from '@angular/core';
import { LYNX_ELEMENTS, LynxViewport } from '@blotch/angular-lynx';

@Component({
  selector: 'app-inbox',
  imports: [LYNX_ELEMENTS],
  template: `
    <view class="flex flex-row h-full">
      <view class="flex-1"><text>Messages</text></view>
      @if (twoPane()) {
        <view class="flex-1"><text>The open message</text></view>
      }
    </view>
  `,
})
export class Inbox {
  readonly #viewport = inject(LynxViewport);
  // The message beside the list on an unfolded phone or a tablet.
  readonly twoPane = computed(() => this.#viewport.width() >= 600);
}
```

Lengths in `%`, `vw`, `vh` and `rpx` follow a new size without code: read these to change what's on the screen, not how big it is. See [Adaptive layouts](/guide/adaptive-layouts.md).

## API

### `LynxViewport`

```typescript
@Injectable({ providedIn: 'root' })
class LynxViewport {}
```

Reads the sizes the [host app](/guide/glossary.md#host-app) sends in its global props, as Lynx's [foldable guide](https://lynxjs.org/next/guide/inclusion/foldable-devices) describes. The apps `ng build --platform` makes send them, and send them again before Lynx lays the page out at a new size, so a template that reads them changes with the layout.

- **A host that doesn't send them**, such as [Lynx Explorer](/guide/glossary.md#lynx-explorer), and the [web preview](/guide/glossary.md#web-preview) still get a `width` and `height` that follow. They come from the window's `resize` event, once Lynx has laid the page out at its new size. `screenWidth` and `screenHeight` then stay the screen's from when the page started.
- **All sizes are in CSS pixels:** points on iOS, dp on Android.

### `LynxViewport.width` and `height`

```typescript
readonly width: Signal<number>;
readonly height: Signal<number>;
```

The page's size: the LynxView's. It's what `100vw`, a page-wide `100%` and an `@media (width …)` rule measure against.

- **With `"edgeToEdge": false`** in `angular.json`, it's the part of the window inside the safe area.
- **On Android, the height is shorter while the keyboard is open:** the app makes room for it. On iOS the keyboard covers the page instead, and the height stays.

### `LynxViewport.screenWidth` and `screenHeight`

```typescript
readonly screenWidth: Signal<number>;
readonly screenHeight: Signal<number>;
```

The app window's size. `750rpx` is its width.

- **It's the window, not the display:** an app sharing the screen in split screen gets its own part, and a folded phone gets its outer screen.
- **A page in a dialog or a card** of your own native app can be smaller than the window. Then the two pairs differ.

### `LynxViewport.orientation`

```typescript
readonly orientation: Signal<ViewportOrientation>;
```

`'portrait'` while the page is at least as tall as it's wide, otherwise `'landscape'`, as `@media (orientation)` decides. It's the page's shape, not the way the phone is held: an unfolded phone held upright, or an app in split screen, can be landscape.

## Types

### `ViewportOrientation`

```typescript
import type { ViewportOrientation } from '@blotch/angular-lynx';

type ViewportOrientation = 'portrait' | 'landscape';
```

## Related

- [Adaptive layouts](/guide/adaptive-layouts.md)
- [System info](/api/angular-lynx/device/system-info.md): the screen's size when the page started
- [Host data](/guide/embedding/host-data.md#what-the-generated-apps-pass)
