UIButton
Defined in: ui/src/UIButton.ts:95
Interactive button for UI panels. Acts as a Yoga flex container — any
UIElement (UIText, UIImage, nested panels) can be added as a child via
addElement. When constructed with a string children, an internal
UIText is auto-added so the builder API (panel.button("Label", ...))
and React JSX strings (<Button>Label</Button>) keep working with no
extra setup. Pass width / height explicitly to fix the size, or omit
them to let Yoga shrink-to-fit the content.
Extends
Section titled “Extends”Implements
Section titled “Implements”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new UIButton(
p):UIButton
Defined in: ui/src/UIButton.ts:144
Parameters
Section titled “Parameters”Returns
Section titled “Returns”UIButton
Overrides
Section titled “Overrides”Properties
Section titled “Properties”_transform
Section titled “_transform”
readonly_transform:ElementTransform
Defined in: ui/src/UIElementBase.ts:20
Internal
Implementation of
Section titled “Implementation of”Inherited from
Section titled “Inherited from”container
Section titled “container”
readonlycontainer:DisplayContainer
Defined in: ui/src/UIButton.ts:96
yogaNode
Section titled “yogaNode”
readonlyyogaNode:Node
Defined in: ui/src/UIButton.ts:97
Implementation of
Section titled “Implementation of”Overrides
Section titled “Overrides”Accessors
Section titled “Accessors”children
Section titled “children”Get Signature
Section titled “Get Signature”get children(): readonly
UIElement[]
Defined in: ui/src/UIButton.ts:291
Returns
Section titled “Returns”readonly UIElement[]
Implementation of
Section titled “Implementation of”disabled
Section titled “disabled”Get Signature
Section titled “Get Signature”get disabled():
boolean
Defined in: ui/src/UIButton.ts:525
Returns
Section titled “Returns”boolean
displayObject
Section titled “displayObject”Get Signature
Section titled “Get Signature”get displayObject():
DisplayContainer
Defined in: ui/src/UIButton.ts:99
Returns
Section titled “Returns”DisplayContainer
Implementation of
Section titled “Implementation of”UIContainerElement.displayObject
Overrides
Section titled “Overrides”focusable
Section titled “focusable”Get Signature
Section titled “Get Signature”get focusable():
boolean
Defined in: ui/src/UIButton.ts:287
Whether the button takes part in focus navigation.
Returns
Section titled “Returns”boolean
focused
Section titled “focused”Get Signature
Section titled “Get Signature”get focused():
boolean
Defined in: ui/src/UIButton.ts:282
Whether the button holds focus in the scope that owns it.
Returns
Section titled “Returns”boolean
rotation
Section titled “rotation”Get Signature
Section titled “Get Signature”get rotation():
number
Defined in: ui/src/UIElementBase.ts:50
See LayoutProps.rotation.
Returns
Section titled “Returns”number
Set Signature
Section titled “Set Signature”set rotation(
value):void
Defined in: ui/src/UIElementBase.ts:54
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Get Signature
Section titled “Get Signature”get scale():
Readonly<{x:number;y:number; }>
Defined in: ui/src/UIElementBase.ts:41
See LayoutProps.scale.
Returns
Section titled “Returns”Readonly<{ x: number; y: number; }>
Set Signature
Section titled “Set Signature”set scale(
value):void
Defined in: ui/src/UIElementBase.ts:45
Parameters
Section titled “Parameters”number | { x: number; y: number; }
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”transformOrigin
Section titled “transformOrigin”Get Signature
Section titled “Get Signature”get transformOrigin():
Readonly<{x:number;y:number; }>
Defined in: ui/src/UIElementBase.ts:32
See LayoutProps.transformOrigin.
Returns
Section titled “Returns”Readonly<{ x: number; y: number; }>
Set Signature
Section titled “Set Signature”set transformOrigin(
value):void
Defined in: ui/src/UIElementBase.ts:36
Parameters
Section titled “Parameters”number | { x: number; y: number; }
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”visible
Section titled “visible”Get Signature
Section titled “Get Signature”get visible():
boolean
Defined in: ui/src/UIButton.ts:529
Returns
Section titled “Returns”boolean
Set Signature
Section titled “Set Signature”set visible(
v):void
Defined in: ui/src/UIButton.ts:533
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Overrides
Section titled “Overrides”zIndex
Section titled “zIndex”Get Signature
Section titled “Get Signature”get zIndex():
number
Defined in: ui/src/UIElementBase.ts:59
See LayoutProps.zIndex.
Returns
Section titled “Returns”number
Set Signature
Section titled “Set Signature”set zIndex(
value):void
Defined in: ui/src/UIElementBase.ts:63
Parameters
Section titled “Parameters”number
Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”Methods
Section titled “Methods”_attachToTree()
Section titled “_attachToTree()”_attachToTree(
context):void
Defined in: ui/src/UIButton.ts:342
Internal
Stamped by UISurface from the owning entity and passed down the tree.
Parameters
Section titled “Parameters”context
Section titled “context”Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”UIContainerElement._attachToTree
_detachFromTree()
Section titled “_detachFromTree()”_detachFromTree():
void
Defined in: ui/src/UIButton.ts:349
Internal
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”UIContainerElement._detachFromTree
_inspectState()
Section titled “_inspectState()”_inspectState():
object
Defined in: ui/src/UIButton.ts:628
Internal
Returns
Section titled “Returns”object
disabled
Section titled “disabled”disabled:
boolean
focusable
Section titled “focusable”focusable:
boolean
focused
Section titled “focused”focused:
boolean
hovered
Section titled “hovered”hovered:
boolean
pressed
Section titled “pressed”pressed:
boolean
activate()
Section titled “activate()”activate():
void
Defined in: ui/src/UIButton.ts:274
Run the button’s action. The click path and the focus scope’s confirm both come through here, behind one disabled guard.
This paints no press and ends none: each device ends its own press, so a call from game code does not disturb a press in progress.
Returns
Section titled “Returns”void
addElement()
Section titled “addElement()”addElement(
child):void
Defined in: ui/src/UIButton.ts:295
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”applyLayout()
Section titled “applyLayout()”applyLayout():
void
Defined in: ui/src/UIButton.ts:356
Apply Yoga-computed positions to children and resize background.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”UIContainerElement.applyLayout
applyTransformProps()
Section titled “applyTransformProps()”
protectedapplyTransformProps(props):void
Defined in: ui/src/UIElementBase.ts:27
Apply the four transform props present in props. A present key holding
undefined resets that prop to its default. Throws before writing
anything if a value is not finite.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Inherited from
Section titled “Inherited from”UIElementBase.applyTransformProps
destroy()
Section titled “destroy()”destroy():
void
Defined in: ui/src/UIButton.ts:645
Idempotent — a second call is a no-op (the React reconciler and a direct caller can both destroy the same instance).
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Overrides
Section titled “Overrides”insertElementBefore()
Section titled “insertElementBefore()”insertElementBefore(
child,before):void
Defined in: ui/src/UIButton.ts:324
Parameters
Section titled “Parameters”before
Section titled “before”Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”UIContainerElement.insertElementBefore
removeElement()
Section titled “removeElement()”removeElement(
child):void
Defined in: ui/src/UIButton.ts:308
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”UIContainerElement.removeElement
setDisabled()
Section titled “setDisabled()”setDisabled(
v):void
Defined in: ui/src/UIButton.ts:510
Parameters
Section titled “Parameters”boolean
Returns
Section titled “Returns”void
setText()
Section titled “setText()”setText(
s):void
Defined in: ui/src/UIButton.ts:499
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”void
update()
Section titled “update()”update(
p):void
Defined in: ui/src/UIButton.ts:538
Parameters
Section titled “Parameters”Partial<UIButtonProps>
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Overrides
Section titled “Overrides”Coding agents: fetch https://yage.dev/llms.txt first and prefer the Markdown references it links over these HTML pages. This page's Markdown counterpart is /llms/packages/ui.md.