UI Divider
Updated
A thin separator line.
- Type
ent-ui-divider- Script class
UIDividerEntity- Family
- UI
Overview
Section titled “Overview”A UI Divider is a thin line that separates parts of a UI: a header from its content, one group of settings from the next, the buttons of a toolbar. Its UI Divider component (comp-ui-divider) draws a line that stretches across its parent unless you give it a fixed length. It is purely visual and takes no pointer.
A divider sits nested in a panel or layout, between the elements it separates. Pick its orientation from its parent’s flow: in a column, a 'horizontal' line separates stacked rows; in a row, a 'vertical' line separates the items side by side.
Use a divider when a visible line helps the eye group things. When you only need space, use the layout’s gap, or a UI Spacer to push elements apart.
The props that matter most:
orientation:'horizontal'(the default) or'vertical'.color: the line colour (the theme’s divider colour by default).thickness: the line thickness in layout pixels (px), 1 by default.length: a fixed length in px instead of stretching.margin: space around the line, in px.
Set it up
Section titled “Set it up”- Add a UI Divider under a UI Panel or UI Layout, between the two elements it separates. See Scenes and hierarchy.
- Set
orientationto match the parent:'horizontal'in a column,'vertical'in a row. - Adjust
color,thicknessandmarginif needed.
Examples
Section titled “Examples”Sections in a settings card
Section titled “Sections in a settings card”Goal: build a card with two sections separated by a divider, all from code.
#pragma lifecycle(startup)
// Scene: a UI Panel named 'Settings'. The script fills it.function startup() { const card = findEntity('Settings'); card.getComponent(UILayoutComponent).setProps({ width: 320, padding: 16, gap: 10 });
const audio = new UILabelEntity(); audio.getComponent(UILabelComponent).setProps({ text: 'Audio', fontWeight: 'bold' }); const music = new UISwitchEntity(); music.getComponent(UISwitchComponent).setProps({ text: 'Music' });
const line = new UIDividerEntity(); line.getComponent(UIDividerComponent).setProps({ color: '#334155', margin: [4, 0] });
const video = new UILabelEntity(); video.getComponent(UILabelComponent).setProps({ text: 'Video', fontWeight: 'bold' }); const shadows = new UISwitchEntity(); shadows.getComponent(UISwitchComponent).setProps({ text: 'Shadows' });
card.add(audio, music, line, video, shadows);}How it works:
- The panel is a column, so the default
'horizontal'divider spans its width between the two sections. margin: [4, 0]adds 4 px above and below the line, on top of the panel’sgap.
A vertical divider in a toolbar
Section titled “A vertical divider in a toolbar”Goal: separate two groups of toolbar buttons with a short vertical line.
#pragma lifecycle(startup)
// Scene: a UI Layout named 'Toolbar' (flexDirection 'row', alignItems 'center')// holding buttons, with a UI Divider named 'Toolbar Split' between two groups.function startup() { const split = findEntity('Toolbar Split').getComponent(UIDividerComponent); split.setProps({ orientation: 'vertical', length: 24, thickness: 2, color: '#475569', margin: [0, 6] });}How it works:
- In a row, a
'vertical'divider stands between items. length: 24keeps it shorter than the buttons; without it, the line stretches to the row’s height.margin: [0, 6]puts 6 px of space on its left and right.
Components
Section titled “Components”What a new UI Divider is made of. Required components are always present and cannot be removed; the others can. Per entity says whether an entity can hold one of that component or several. Layer, Lock and Enable are on every placed entity, and Transform holds its position, rotation and scale.
| Component | Type | Role | Per entity | What it does |
|---|---|---|---|---|
| Layer | comp-layer |
Required | One | Puts the entity on a render/raycast layer so cameras and rays can include or skip it. |
| Lock | comp-lock |
Required | One | Editor-only flag that stops the entity from being selected or moved. |
| Enable | comp-enable |
Required | One | Turns the entity and its children on or off: hides them and stops their behavior. |
| Transform | comp- |
Required | One | Position, rotation and scale of the entity, with optional editor-only per-axis locks. |
| UI Divider | comp- |
Required | One | A thin separator line. |
You can also add 1 optional components, such as Signal Emitter.
The settings of a new entity, as the runtime creates it. Change them in the Properties panel of XR Creator, or from a script with getComponent(…).setProps({ … }).
| Prop | Default | Range |
|---|---|---|
orientation |
"horizontal" |
Events
Section titled “Events”With a Signal Emitter on the entity, these events reach scripts as { entityId, eventType, data }. Compare eventType with the EventType constants.
It reports the events every entity has: Transform::change (and position-change, rotation-change, scale-change), Enable::change, Layer::change and Lock::change.
Live example
Section titled “Live example”Run it in the browser, read its scripts, and download it as an XR Creator project.
A profile card built from a UI Avatar with initials and a status dot, a UI Spacer that pushes the level badge right, and UI Dividers between the stats. Pressing the avatar cycles the status.
Press the avatar to cycle Online, Away and Busy: the status dot and the label change together. Drag outside the panel to orbit the camera, scroll to zoom.
From a script
Section titled “From a script”Find the entity by its name, check its class, and work with its components. Name the entity in the Hierarchy first; this example expects My UI Divider.
#pragma lifecycle(startup)
function startup() { // Find the entity by the name it has in the Hierarchy. const entity = findEntity('My UI Divider'); if (!(entity instanceof UIDividerEntity)) return;
// Its UI Divider component holds the settings listed under Props. const component = entity.getComponent(UIDividerComponent); log(component.props);}