Skip to content

Layout constraints reference

Constraints are passed as the second argument to addComponent and tell a LayoutManager how to position a child. Each manager defines its own constraint shape — see the per-layout pages for specifics.

This page covers the shared constraint primitives that several managers consume.

LayoutConstraints

The base LayoutConstraints exposes two universally relevant fields:

FieldPurpose
fillFillType — how the child expands to use available cell space.
anchorAnchorType — where to position the child within its cell when it doesn't fill it.

Plus optional metadata:

FieldPurpose
nameLabel / identifier; consumed by Tab for tab button text.
descriptionFree-form descriptive string for accessibility / debugging.

Each manager subclasses this to add its own fields:

FillType

FillType controls how a child expands to fill its allocated cell:

ValueBehaviour
NONEUse the child's preferred size; no expansion.
HORIZONTALStretch horizontally to fill the cell width.
VERTICALStretch vertically to fill the cell height.
BOTHFill the entire cell.
typescript
import { FillType } from '@jimka/typescript-ui/layout';
container.addComponent(input, { fill: FillType.HORIZONTAL });

AnchorType

AnchorType tells the layout where to position a child when its preferred size is smaller than its allocated cell. The values follow compass directions plus the centre:

NORTHWEST  NORTH  NORTHEAST
WEST      CENTER  EAST
SOUTHWEST  SOUTH  SOUTHEAST
typescript
import { AnchorType } from '@jimka/typescript-ui/layout';
container.addComponent(label, {
    fill:   FillType.NONE,
    anchor: AnchorType.NORTHEAST,
});

Placement

Placement is a separate enum used by Border for region selection (and by Window to describe edge-resize handles):

ValueRegion
NORTHTop
SOUTHBottom
WESTLeft
EASTRight
CENTERMiddle

See also