Skip to main content
Viewport renders a fixed-size window over content that is larger than the screen. The user can scroll vertically (and optionally horizontally) with keyboard shortcuts or the mouse wheel.

Quick start

Constructors

Setting content

Content is split on newlines. CRLF line endings are normalised to LF automatically.

Dimensions

Handle WindowSizeMessage in your update() to keep the viewport sized to the terminal:

Programmatic scrolling

Scroll position

Horizontal scrolling

Styling

The viewport respects the border’s frame size when computing visible line counts and the horizontal scroll range.

Mouse wheel

Mouse wheel scrolling is enabled by default. The scroll delta (lines per notch) defaults to 3.

High-performance rendering

When running inside a full-screen AltScreen layout, enable high-performance rendering to let the renderer diff only the changed lines rather than redrawing the full viewport on every frame:

Keyboard navigation

Textarea

Editable multi-line input.

Components overview

Back to all components.