Skip to content

@jsvision/ui / fixed

Function: fixed()

fixed<V>(view, n): V

Defined in: ui/src/view/dsl/flex.ts:231

Give a view a fixed size of n cells along its container's main axis (columns in a row, rows in a col). Mutates the view's layout.size (preserving its other layout props) and returns the same view, so it composes inline inside a col/row.

Re-tagging an already-mounted view requests a reflow for you — no manual invalidateLayout().

Type Parameters

V

V extends View

Parameters

view

V

The view to size.

n

number

The fixed extent in whole cells.

Returns

V

The same view, for inline chaining.

Example

ts
import { View, col, fixed, grow, 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); }
}

// A 3-row status bar pinned below a growing body.
const body = new Panel('body');
const statusBar = new Panel('status');
const app = col(grow(body), fixed(statusBar, 3));