Skip to content

@jsvision/ui / centered

Function: centered()

centered<V>(view, width, height): V

Defined in: ui/src/view/dsl.ts:392

Tag a view as a centered fixed-size stack layer (width × height, centered on both axes). It re-centers itself lag-free when the stack resizes.

Type Parameters

V

V extends View

Parameters

view

V

The layer view.

width

number

Fixed width in cells.

height

number

Fixed height in cells.

Returns

V

The same view, for inline chaining inside a stack(...).

Example

ts
import { stack, centered } from '@jsvision/ui';

const screen = stack(canvas, centered(dialog, 40, 12));