Appearance
UI beta
View tree builders. Each method returns a plain View descriptor, the same shape the editor stores for a panel's views. Compose into a panel via createPanel(content, options) and instantiate with scene.createEntity.
Naming a node ({ name: 'vol' }) lets you find it later via entity.representation.findView({ name: 'vol' }) to bind a variable, attach a listener, or mutate properties.
Common options accepted by every factory: - name – author-supplied lookup key for findView({ name }). - padding – number (uniform), { horizontal, vertical }, or { top, leading, bottom, trailing }. - background, overlay – views drawn behind or in front of this one, made with these factories. They never change its size or move its neighbours. - placement – where a view in a background or overlay sits: { alignment, anchor }, each a point named 'topLeading' … 'bottomTrailing' or 'center', [x, y] from (0, 0) top leading to (1, 1) bottom trailing, or a Vector2. alignment is the point on the view it belongs to, anchor the point on this view placed there; both default to the centre. A badge centred on a corner is { alignment: 'topTrailing' }; inside it, { alignment: 'topTrailing', anchor: 'topTrailing' }. - style – { foregroundColor, backgroundColor, font, shape, opacity, … }. Colours take '#RRGGBB[AA]', { r, g, b, a? } or { light, dark }; shape takes 'rectangle', 'capsule', 'circle' or a corner radius in points. On a button, prominence: 'expressive' draws Liquid Glass in panels on the screen, tinted with its backgroundColor, or blue for appearance: 'primary' and red for 'destructive'. - safeAreaPadding – edges whose padding grows by the safe area, as an array of 'top', 'leading', 'bottom' and 'trailing'. Use it in a panel anchored with Anchor.screenSpace({ respectsSafeArea: false }), so a header image can reach the screen edge while text and buttons stay clear of the status bar, the home indicator and rounded corners. Adds nothing while the panel respects the safe area. - sizing – sets width/height per axis. Each axis accepts: 'auto' (hug content, default), 'fill' (take available space), a number in points (fixed), or a percentage string like '50%'. Pass sizing: 'fill' for both axes, sizing: [w, h] for fixed both axes, or sizing: { width: 'fill', height: 'auto', maxWidth: 600 } for mixed control. Sliders and progress views default to fill on the stack's cross axis (they have no intrinsic width / height to hug); set sizing: { width: 200 } if you want a narrower control instead. - isHidden, isEnabled, opacity – universal interactive flags.
Methods
animate()
javascript
UI.animate(changes: function, options?: Object): PromiseAnimates every change to panel views made inside changes: a stack opens or closes around views shown or hidden, new views fade in, opacity and size changes ease, and the panel grows or shrinks with them. Without it the same changes happen at once.
Example:
javascript
// Open a category in a list: its rows fade and slide in, and the panel grows.
header.on('tap', () => {
const opening = rows.isHidden;
if (opening) { rows.opacity = 0; }
UI.animate(() => {
rows.isHidden = !opening;
rows.opacity = opening ? 1 : 0;
});
});
// A list item fades in where it is added.
UI.animate(() => list.add(sample.copy()), { duration: 0.25 });Parameters:
changes(function) - Makes the changes, the same way as without an animation.options(Object) (optional) - Timing, as inanimateTo; the system's default when left out.options.duration(number) (optional) - Seconds.options.timingFunction(string) (optional) - 'linear' | 'easeIn' | 'easeOut' | 'easeInOut'options.spring(Object) (optional) - Spring timing instead ofdurationandtimingFunction.options.spring.duration(number) (optional) - The spring's perceived duration in seconds.options.spring.bounce(number) (optional) - 0 settles without overshoot, higher values bounce.
Returns: Promise
annotation() beta
javascript
UI.annotation(opts: Object): voidA marker pinned to a point, which expands into a card.
The card is the single child, so card: is sugar for children: [view]. Without one the annotation is just a marker and tapping it does nothing.
The marker keeps its authored point size only where the panel is drawn as a screen overlay. In world space it is a physical object and shrinks with distance; the object's Dynamic Scale constraint, set in the editor, keeps it readable at any range.
Example:
javascript
var hotspot = UI.annotation({
name: 'port',
title: '1',
direction: 'up',
card: UI.vStack({
spacing: 2,
children: [
UI.label({ text: 'Charging port', style: { font: { size: 15, weight: 'semibold' } } }),
UI.label({ text: 'USB-C, 140W' })
]
})
});
// Later, from anywhere:
entity.representation.findView({ name: 'port' }).isExpanded = true;Parameters:
opts(Object) - { card?, isExpanded?, direction?, animation?, marker?, title?, image?, stem?, leader?, cardStyle?, shadow?, name?, ... }.opts.card(Object) (optional) - View shown when expanded, typically a UI.vStack.opts.isExpanded(boolean) (optional) - Starting state, not an entrance.opts.direction(any | any | any | any) (optional) - Which way the stem and card grow away from the marker.opts.animation(any | any | any) (optional) - How the card arrives.opts.marker(Object) (optional) - { kind?: 'filled'|'ring'|'ringWithCenter', diameter?, ringWidth?, centerScale?, fillColor?, ringColor? }.opts.title(string) (optional) - Glyph drawn inside the marker, e.g. a number.opts.image(string) (optional) - SF Symbol name drawn inside the marker.opts.stem(Object) (optional) - { isEnabled?, lineStyle?: 'solid'|'dashed'|'dotted', length?, thickness?, color? }.isEnabled: falsestill holds the cardlengthaway from the marker. Ignored entirely whenleaderis set, since the card then opens at the marker.opts.leader(Object) (optional) - A line from the annotated point out to the marker, so the marker floats clear of the subject. Same shape asstem. Set, the point takes the annotation's centre, the marker liftslengthaway alongdirection, and the card opens at the marker with no second line between them.opts.cardStyle(Object) (optional) - { cornerRadius?, backgroundColor?, contentInsets? }.
Returns: void
button()
javascript
UI.button(opts: Object): voidTap-able button.
Parameters:
opts(Object) - { title, icon?, iconPointSize?, iconOffset?, name?, ... }.iconOffsetis[x, y]in points and moves the icon without resizing the button.
Returns: void
carousel()
javascript
UI.carousel(opts: Object): voidCarousel: a row or column of children that scrolls and selects the child in the middle. Listen with on('valueChanged', …) for the selected index, or on('scroll', …) for the position while it moves; scrollTransition shrinks, fades or tilts children by their distance from the middle.
Example:
javascript
var rooms = UI.carousel({
name: 'rooms',
spacing: 12,
neighborScale: 0.85,
children: ['Kitchen', 'Studio', 'Garden'].map(function(room) {
return UI.label({ text: room, sizing: [160, 100] });
})
});Parameters:
opts(Object) - { children?, axis?, spacing?, itemSize?, selectedIndex?, snapsToItems?, isScrollLocked?, showsPageDots?, neighborScale?, neighborOpacity?, playsSelectionHaptics?, name?, ... }.axisis'horizontal'(default) or'vertical'.itemSizeis'fitContent'(default) or'matchLargest', which gives every child the length of the longest alongaxis.snapsToItems(default true) brings a released scroll to rest with a child in the middle.isScrollLockedlets only a script or a bound variable move it.neighborScaleandneighborOpacity(default 1) are what a child one step from the middle gets.
Returns: void
divider()
javascript
UI.divider(opts: Object): voidThin horizontal separator.
Parameters:
opts(Object) - { thickness?, ... }.
Returns: void
hStack()
javascript
UI.hStack(opts: Object): voidHorizontal stack.
Parameters:
opts(Object) - { children?, alignment?, distribution?, spacing?, ... }.
Returns: void
label()
javascript
UI.label(opts: string | Object): ObjectLabel (read-only text). Accepts a string shorthand or an options object.
Text supports live variable interpolation – ${var} reads from the current segment, ${g:var} from the experience scope. The label re-renders automatically whenever a referenced variable changes; no manual scene.on('variableChange', …) wiring is needed. Optional |filter / |filter(arg) suffix formats the resolved value: fixed(N), percent(N), time, int, signed(N). Missing variables render as UNDEFINED. See the "Live Labels" guide for the full filter reference.
Example:
javascript
// Plain label
UI.label('Hello world')
// Live-bound value with a formatter
UI.label({ text: 'Volume: ${vol|fixed(2)}' })
// Global score + formatted timer in one label
UI.label({ text: 'Score: ${g:score|int} · ${countdown|time}' })Parameters:
opts(string | Object) - Text shorthand or { text, lineLimit?, textTransform?, name?, ... }.
Returns: Object
progressView()
javascript
UI.progressView(opts: Object): voidDeterminate (progress: 0..1) or indeterminate (omit progress) progress bar.
Parameters:
opts(Object) - { progress?, name?, ... }.
Returns: void
segmentedControl()
javascript
UI.segmentedControl(opts: Object): voidSegmented control.
Parameters:
opts(Object) - { segments: [...], selectedIndex?, name?, ... }.
Returns: void
shape()
javascript
UI.shape(opts: Object): voidDecorative shape fill.
Parameters:
opts(Object) - { shape?, ... }.shapedefaults to a rounded rectangle.
Returns: void
slider()
javascript
UI.slider(opts: Object): voidContinuous or stepped slider.
Parameters:
opts(Object) - { value?, range?|min,max, numberType?, step?, name?, ... }.
Returns: void
spacer()
javascript
UI.spacer(opts: Object): voidFlexible empty space.
Parameters:
opts(Object) - { minLength?, ... }.
Returns: void
stepper()
javascript
UI.stepper(opts: Object): voidStepper (− / + numeric increment).
Parameters:
opts(Object) - { value?, range?|min,max, step?, label?, name?, ... }.
Returns: void
textField()
javascript
UI.textField(opts: Object): voidSingle-line text field.
Parameters:
opts(Object) - { text?, placeholder?, name?, ... }.
Returns: void
toggle()
javascript
UI.toggle(opts: Object): voidOn/off switch.
Parameters:
opts(Object) - { isOn?, label?, name?, ... }.
Returns: void
vStack()
javascript
UI.vStack(opts: Object): voidVertical stack.
Parameters:
opts(Object) - { children?, alignment?, distribution?, spacing?, ... }.
Returns: void
zStack()
javascript
UI.zStack(opts: Object): voidZ-axis stack (layers children).
Parameters:
opts(Object) - { children?, alignment?, ... }.
Returns: void