NUI / Components / Layout
ScaleBox
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.
children {
Text ChildText {
text: "THIS IS THE CHILD COMPONENT"
}
}Basic syntax
ScaleBox FittedTitle {
fit: contain
children {
Text ChildText {
text: "THIS IS THE CHILD COMPONENT"
}
}
}Supported properties
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
fit | enum | No | contain | Scale fit mode. |
width | number | No | Auto | Desired width. |
height | number | No | Auto | Desired height. |
minWidth | number | No | Unset | Minimum width. |
minHeight | number | No | Unset | Minimum height. |
maxWidth | number | No | Unset | Maximum width. |
maxHeight | number | No | Unset | Maximum height. |
padding | margin | No | margin(0) | Inner padding. |
horizontalAlign | enum | No | Inherited | Component horizontal alignment. |
verticalAlign | enum | No | Inherited | Component vertical alignment. |
contentHorizontalAlign | enum | No | Inherited | Child horizontal alignment. |
contentVerticalAlign | enum | No | Inherited | Child vertical alignment. |
layer | integer | No | Context default | Layer order inside layered parents. |
visible | bool | No | true | Visibility 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
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.