Skip to content

Placement and fonts

Updated

This page answers two practical questions. First, where does a UI element end up? It depends only on its parent: inside a panel it is laid out, under a 3D object it floats in the world. Second, what does its text look like? Every piece of UI text draws with a font family chosen by name, from the families that ship with the runtime, the project’s own, or ones a script registers at run time with Fonts.

Any UI element can go anywhere in the hierarchy; nothing is rejected for its parent. Where it goes decides how it is placed:

Parent The element is
A 3D object, or the scene root The root of its own UI, drawn in the world at its entity’s transform, at pixelSize metres per layout pixel (0.003 m by default). It moves with its parent. Scale the entity to size it.
A UI Layout or UI Panel Laid out inside it by the parent’s layout.
A control (a button, a label…) Taken into the control’s own box.
A control with a UI Menu Put into the menu’s popup. See Controls.
  • Transform. A nested element’s Transform has no effect, and neither does a root’s under UI Screen Space. The editor disables their transform fields and gizmo and says why.
  • Only the direct parent counts. A UI element under a plain Group under a panel is a root of its own, not part of the panel’s layout.
  • Order. Children are laid out in hierarchy order.
  • Cost. Each free-standing root is its own tree with its own layout and drawing. Many elements under one panel cost less than as many separate roots.
  • Across scenes. A UI Panel takes a Don’t Unload component, for a HUD or inventory kept across scene switches; its controls travel with it.

A label that floats over an object is a UI Label placed under that object, raised above it, and turned to the camera by a Billboard component. Because it is a child of the object, it follows the object wherever it moves. A Billboard on a UI root turns the drawn UI, never the saved transform, so it also works while you edit.

A UI Label draws its text inside a box styled with CSS names:

  • padding is the space inside the box, 1 px by default; margin the space outside it, none by default. Both take one number or one to four, clockwise from the top.
  • backgroundColor and borderRadius fill the box and round its corners.
  • borderColor and borderWidth draw a solid border, only when borderColor is set. Its width defaults to 2 px. Like a CSS border, it takes space inside the box.
  • width, maxWidth, minHeight and maxHeight size the box; text past maxHeight is clipped or scrolls, per overflow.

A label wraps at word boundaries. A long run with no spaces, such as a URL or a code, can overflow a narrow panel. Give the label a width or maxWidth and set overflowWrap: true: it keeps normal word wrapping and breaks inside a word only when that word is wider than the label. For full control, wordBreak takes 'break-word', 'break-all' (break anywhere) or 'keep-all' (never inside a word, which wins over overflowWrap). Wrapped text grows the label; cap it with maxHeight and overflow: 'hidden' or 'scroll'.

Every text renderer picks its font from one list of font families, by name, through its font prop: UI text (labels, buttons, controls, notifications, the AI caption and dialog), world-space Text and Text 3D, and the ASCII effect. A family is a typeface such as Inter, available in one or more weights ('light', 'normal', 'medium', 'semi-bold', 'bold').

Five families ship with the runtime:

Family Look Weights Characters
inter (default) Neutral sans light, normal, medium, semi-bold, bold Latin with accents, Greek, Cyrillic, punctuation, currencies, arrows and symbols such as ✓ ✗ ★ ♥
roboto System-style sans normal, bold Latin with accents, typographic punctuation, currency and signs
nunito Rounded, friendly normal, bold As Roboto
montserrat Geometric display normal, bold As Roboto, plus arrows
jetbrains-mono Monospace normal, bold As Roboto, plus arrows, ✓ ✗

Every family has accented Latin letters, ñ, ¿ ¡, typographic punctuation (… – — “ ” ‘ ’ • ·) and common signs (€ £ ¥ © ® ™ ± × ÷).

  • The default. The project’s theme sets the font for the whole UI; unset, it is Inter. A UI Label or UI Button takes its own font, and a notification theme takes fontFamily.
  • A family not registered. UI text naming a family that is not registered yet draws in Inter, and switches when the family registers. Every open UI rebuilds once when a family is registered or removed.
  • Loading. A weight loads the first time some text uses it, so unused fonts cost nothing, and a scene without UI text loads none.
  • A project’s own fonts. A project can save font families of its own; they appear in the list like the bundled ones and are named the same way.

Emojis in UI text draw in colour, inline with the letters, in every family: labels, buttons, notifications, tooltips and text inputs. That includes flags, keycaps and joined sequences such as 👨‍👩‍👧. Skin-tone variants draw with the default yellow tone. An emoji is about the size of the font; color does not tint it, while opacity and fading apply. A scene whose text has no emoji downloads nothing for them. World-space Text and Text 3D draw no emojis. The emoji images are licensed under CC-BY 4.0: credit them in your product’s credits. See Emoji moods.

The Fonts global registers a font file as a family for the session. Every text whose font names that family draws with it from then on.

GlobalWhat it is
FontsThe app's font families: await Fonts.register(family, url, { weight, label }) for this session, unregister, has(family), families.
Member What it does
await Fonts.register(family, url, { weight?, label? }) Load a .ttf, .otf or .woff file and register it as family, in the weight slot ('normal' by default). label is the name an editor shows. Registering the same family and weight again replaces it. Rejects when the file is not a usable font, or family is a bundled family or not a name of 1 to 64 characters.
Fonts.unregister(family) Remove a registered family, or one the project saves, until the project loads again; texts using it go back to their default. Returns false for a bundled or unknown family.
Fonts.has(family) Whether family can be drawn with now.
Fonts.families Every family as { name, label, look }, the bundled ones first.
  • A registered family lasts for the session, after the script is released too, and is never saved. Every player runs the same scripts, so each registers it on their own device.
  • A family missing a weight draws with the nearest one it has.
NameTag.jx
#pragma lifecycle(startup)
function startup() {
const box = findEntity('Lemon Box');
const tag = new UILabelEntity();
tag.getComponent(UILabelComponent).setProps({
text: 'Lemon Box',
fontSize: 40,
padding: 12,
backgroundColor: 'rgba(28, 28, 30, 0.9)',
borderRadius: 14,
borderColor: '#69ebed',
});
tag.position.set(0, 0.8, 0);
tag.addComponent(new BillboardComponent());
box.add(tag);
}

How it works:

  • The label is added under the box, so it is a root of its own placed by its own transform, 0.8 m above the box’s origin, and it moves with the box.
  • The Billboard turns the label to face the camera wherever the player stands.
  • The box styling (padding, fill, rounded corners, border) comes from the label’s own props.

Emojis are ordinary characters in UI text. Each button’s text is one emotion emoji; pressing one copies it into the big label.

Moods.jx
#pragma lifecycle(startup)
function startup() {
const mood = findEntity('Mood').getComponent(UILabelComponent);
on('mood:pick', (event) => {
const emoji = findEntity(event.entityId).getComponent(UIButtonComponent).props.text;
mood.setProps({ text: emoji });
log('Mood:', emoji);
});
}
  • The big label is the same emoji at a larger fontSize: an emoji is sized like the letters around it.
AllTags.jx
#pragma lifecycle(startup)
// Scene: a Group named 'Exhibits' whose children are the objects to label.
// Each child's name becomes its tag.
function makeTag(text) {
const tag = new UILabelEntity();
tag.getComponent(UILabelComponent).setProps({
text,
fontSize: 28,
font: 'nunito',
padding: [6, 12],
backgroundColor: '#0f172a',
borderRadius: 10,
});
tag.addComponent(new BillboardComponent());
return tag;
}
function startup() {
const exhibits = findEntity('Exhibits');
for (const child of [...exhibits.children]) {
if (!isEntity(child)) continue;
const tag = makeTag(child.name);
tag.position.set(0, 1.2, 0);
child.add(tag);
}
}

How it works:

  • The loop copies the children list first ([...exhibits.children]), because adding tags changes the hierarchy while it is being walked.
  • isEntity skips plain objects that are not entities, such as meshes inside a model.
  • Each tag uses the bundled nunito family through its font prop.
FontPicker.jx
#pragma lifecycle(startup)
// Scene: a UI Label named 'Sample' and a UI Button named 'Next Font'
// with a Signal Emitter on 'fonts/next'.
let index = 0;
function startup() {
const sample = findEntity('Sample').getComponent(UILabelComponent);
const button = findEntity('Next Font').getComponent(UIButtonComponent);
function apply() {
const families = Fonts.families;
const family = families[index % families.length];
sample.setProps({ text: `${family.label}: The quick brown fox`, font: family.name });
button.setText(`Font ${(index % families.length) + 1} of ${families.length}`);
}
on('fonts/next', (event) => {
if (event.eventType !== EventType.UIButton.Press) return;
index += 1;
apply();
});
apply();
}

How it works:

  • Fonts.families lists every family, bundled ones first, each with a name to put in font and a readable label.
  • The list is read again on each press, so families registered later by another script appear too.
Section titled “5. A long link that stays inside its panel”
ShareLink.jx
#pragma lifecycle(startup)
// Scene: a UI Panel 320 px wide with a UI Label named 'Link'.
function startup() {
const link = findEntity('Link').getComponent(UILabelComponent);
link.setProps({
text: 'https://example.com/rooms/7f3a9c21b4e84d0f9a6e/invite?from=lobby',
font: 'jetbrains-mono',
fontSize: 14,
maxWidth: 280,
overflowWrap: true,
maxHeight: 60,
overflow: 'hidden',
});
}

How it works:

  • maxWidth gives the label a width to wrap at, and overflowWrap: true lets it break inside the long URL, which has no spaces.
  • maxHeight with overflow: 'hidden' caps the label at about three lines, so a very long link cannot push the panel’s other content away.
BrandFont.jx
#pragma lifecycle(startup)
// Scene: a UI Label named 'Headline'. The project ships the font files
// /assets/Branda.ttf and /assets/Branda-Bold.ttf.
async function startup() {
const headline = findEntity('Headline').getComponent(UILabelComponent);
headline.setProps({ text: 'Grand Opening', fontSize: 48, font: 'branda' });
try {
await Fonts.register('branda', '/assets/Branda.ttf', { label: 'Branda' });
await Fonts.register('branda', '/assets/Branda-Bold.ttf', { weight: 'bold' });
headline.setProps({ fontWeight: 'bold' });
} catch (error) {
log('Branda could not load, keeping the default font:', error.message);
headline.setProps({ font: 'montserrat' });
}
}

How it works:

  • The label names branda before the family exists; it draws in Inter until the family registers, then switches by itself.
  • Each register call fills one weight slot of the family: normal first, then bold.
  • register rejects when the file is not a font it can use. The catch falls back to a bundled family instead of leaving the error unhandled, which would stop the script.
  • A UI element under a Group inside a panel. Only the direct parent counts; it becomes a separate root. Put UI directly under the panel or a UI Layout.
  • Moving a nested element by its position. The layout places it. Move it with layout props, or make it a root.
  • Forgetting the Billboard. A pinned label without one keeps its own rotation and is unreadable from behind.
  • Characters that do not show. The bundled fonts do not cover Arabic, Hebrew, Indic or CJK scripts. Choose content the fonts cover.
  • An unhandled register failure. Fonts.register returns a promise that rejects on a bad file. await it inside try/catch in an async hook.
  • Expecting a run-time font to be saved. A family registered with Fonts lasts for the session only; a font the project should keep belongs in the project’s own fonts.