Skip to content

GoX tags ​

Tags in a GoX template are native GPUI elements rather than HTML. Unknown tags and attributes make nativegox.Build return an error.

TagBuildsDefault role
divContainerRoleGeneric
spanContainerRoleGeneric
textContainerRoleGeneric
buttonFocusable containerRoleButton
inputText input, and must be a void tagRoleTextInput

span and text are plain containers for their child text, with no inline layout behavior. GoX's synthetic containers become transparent fragments and accept no attributes.

Attributes ​

AttributeApplies toAccepted value
testidAll tagsstring, registered with the document like Name
labelAll tagsstring accessibility label
roleAll tagsscene.AccessibleRole, other than RoleUnspecified
styleAll tags*scene.Style, or func() *scene.Style to read signals
onClickAll tagsui.Handler, or func(context.Context, *client.Event) error
checkedAll tagsbool, or func() bool to read signals
valueinput*reactive.Signal[string], required
placeholderinputstring
disabledinputbool, or func() bool to read signals
maskedinputbool, or func() bool to read signals. Draws bullets instead of the text

Text content ​

Literal text between tags becomes a static text node, shown as written with no HTML parsing. For text that changes, wrap an accessor in nativegox.Text:

text
<span>
	~(nativegox.Text(func() string { return fmt.Sprintf("Count: %d", count.Get()) }))
</span>

Writing ~(count.Get()) instead formats the value once, and it never updates. A bare function value returns an error. A *ui.Node can be embedded as a child, including the result of Show and For.

Button ​

text
<button label="Increment" onClick=(increment) style=(&scene.Style{
	Padding: scene.Padding(12),
	Background: scene.RGB(0x4f46e5),
})>
	Increment
</button>

A centered counter reading Count: 3 above an Increment button

The repository's GoX counter example, built from a template using these tags.

Input ​

input is a void tag and must have a value signal:

text
<input value=(name) placeholder="Your name" disabled=(locked.Get) />

Building ​

text
func Build(ctx context.Context, document *ui.Document, owner *reactive.Scope, element gox.Elem) (*ui.Node, error)

Build runs the component once and requires exactly one root element. A failed build disposes everything it created.

GoX's own if and for run during that one construction. For structure that changes over time, use Show and For and embed the result.

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