NUI / Components / Layout

ScaleBox

ImplementedLayout

ScaleBox wraps exactly one child and scales it according to a fit mode.

Supported as a one-child scale and fit wrapper.

Overview

ScaleBox wraps exactly one child and scales it according to a fit mode.

When to use

  • Use ScaleBox when a child should scale to fit available space.

Children

Supports exactly one child.

nui
children {
    Text ChildText {
        text: "THIS IS THE CHILD COMPONENT"
    }
}

Basic syntax

nui
ScaleBox FittedTitle {
    fit: contain

    children {
        Text ChildText {
            text: "THIS IS THE CHILD COMPONENT"
        }
    }
}

Supported properties

PropertyTypeRequiredDefaultDescription
fitenumNocontainScale fit mode.
widthnumberNoAutoDesired width.
heightnumberNoAutoDesired height.
minWidthnumberNoUnsetMinimum width.
minHeightnumberNoUnsetMinimum height.
maxWidthnumberNoUnsetMaximum width.
maxHeightnumberNoUnsetMaximum height.
paddingmarginNomargin(0)Inner padding.
horizontalAlignenumNoInheritedComponent horizontal alignment.
verticalAlignenumNoInheritedComponent vertical alignment.
contentHorizontalAlignenumNoInheritedChild horizontal alignment.
contentVerticalAlignenumNoInheritedChild vertical alignment.
layerintegerNoContext defaultLayer order inside layered parents.
visibleboolNotrueVisibility flag.

Contextual properties

Contextual property rules

ScaleBox may receive stack, canvas, grid, wrap, or ExpandableArea slot properties only when it is authored as a direct child of the matching parent. See section 7.

Full syntax example

nui
ScaleBox FittedTitle {
    fit: contain
    width: 220
    height: 64
    minWidth: 120
    minHeight: 32
    maxWidth: 360
    maxHeight: 120
    padding: margin(4)
    horizontalAlign: center
    verticalAlign: center
    contentHorizontalAlign: center
    contentVerticalAlign: center
    layer: 1
    visible: true

    children {
        Text ChildText {
            text: "THIS IS THE CHILD COMPONENT"
        }
    }
}

Limitations

  • ScaleBox must contain exactly one child.
  • Aspect-ratio properties belong to Box and SizeBox, not normal ScaleBox public syntax.