Skip to content

@jsvision/ui / place

Function: place()

place<V>(view, placement): V

Defined in: ui/src/view/dsl/stack.ts:272

Tag a view with a Placement for use as a stack layer, and return the same view for inline composition. Without a tag, a stack layer fills the whole box; a tag pins it to an edge, corner, or center.

Type Parameters

V

V extends View

Parameters

view

V

The layer view to tag.

placement

Placement

Where the layer should sit within the stack box.

Returns

V

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

Example

ts
import { View, stack, place, type DrawContext } from '@jsvision/ui';

class Panel extends View {
  constructor(private readonly label: string) { super(); }
  draw(ctx: DrawContext) { ctx.fill(' ', ctx.color('window')); ctx.text(1, 0, this.label); }
}

// Pin a 20×3 panel to the bottom-left corner of the overlay.
const canvas = new Panel('canvas');
const panel = new Panel('panel');
const screen = stack(canvas, place(panel, { h: 'start', v: 'end', width: 20, height: 3 }));