Skip to content

Element reference ​

Every view is a tree of six native element kinds. The same elements are reachable from three APIs, at different levels of coverage.

One window showing all six element kinds: container, text, text input, image, canvas and uniform list

Elementscene snapshot APIui reactive APIGoX tag
Containerscene.DivDocument.Divdiv, span, text, button
Textscene.TextDocument.Text, Document.BindTextLiteral text, nativegox.Text
Text inputscene.TextInputDocument.Inputinput
Imagescene.ImageNot availableNot available
Canvasscene.CanvasNot availableNot available
Uniform listscene.UniformListNot availableNot available

With the optional Zed editor, scene.Embedded places a live editor in the tree.

Beyond the elements themselves, see Node methods for what applies to every element, Style properties for each style field and Events for what handlers receive.

Features by area ​

AreaAPI and behavior
ResourcesUploadResource, Image, Resource.Release: PNG, JPEG, GIF and WebP images, SVG icons and fonts
DrawingCanvas: rectangles and filled or stroked paths, including quadratic and cubic curves
ListsUniformList, Window.ScrollTo: native scroll state, with layout and paint of visible rows only
KeyboardFocusable, BindKey, BindKeyWithContext, OnAction, Window.DispatchAction: key contexts, predicates and multi-stroke chords
Input eventsInteract, OnEvent: keys, mouse, scrolling, focus changes, external file drops and in-process drag-and-drop
AccessibilityAccessible: roles, labels, descriptions, selection, expanded and checked state, and values
StyleFlex, grid and hidden display, wrapping, opacity, font families, alignment, italics and shadows. Animate covers opacity
ModelsCreateModel, Read, revision-checked Update, Observe, Release: Rust-owned entities holding opaque bytes
PlatformWindow title, size and state; clipboard text; opening URLs; native menus; asynchronous open and save dialogs

A model change does not rebuild a view by itself: your callback decides whether to call Window.Set. Path dialogs return paths without reading or writing files.

Rules for every snapshot ​

The Rust side validates each snapshot before changing anything on screen. If validation fails, the call that installed it returns an error and the previous view stays in place.

RuleLimit
Element IDNonzero, and unique within the view
Elements per view10,000, counting list rows and their descendants
Tree depth32
Encoded message size4 MiB
Click handler IDNonzero
Unknown or unspecified enum valueRejected, so leave a field unset rather than passing an Unspecified constant

Element IDs ​

In the scene API you choose the IDs. Keep each one stable for as long as it names the same control: the ID is what ties a snapshot's element to native state such as focus, hover, text selection and scroll position. Reusing an ID for a different control carries that state over, and changing an ID loses it.

The ui API and GoX allocate IDs for you, and each node keeps its ID for its lifetime.

Builders ​

scene functions return a *scene.Node, and its methods return the same node so calls can chain. Builders are mutable and belong to one goroutine. Passing a child to scene.Div copies it, so changing the child afterward has no effect on the parent.

Passing a nil child, or a nil image resource, panics.

Released under the Apache License 2.0. The optional Zed editor component is GPL-3.0-or-later.