Skip to content

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.

new UIButton(p): UIButton

Defined in: ui/src/UIButton.ts:144

UIButtonProps

UIButton

UIElementBase.constructor

readonly _transform: ElementTransform

Defined in: ui/src/UIElementBase.ts:20

Internal

UIContainerElement._transform

UIElementBase._transform


readonly container: DisplayContainer

Defined in: ui/src/UIButton.ts:96


readonly yogaNode: Node

Defined in: ui/src/UIButton.ts:97

UIContainerElement.yogaNode

UIElementBase.yogaNode

get children(): readonly UIElement[]

Defined in: ui/src/UIButton.ts:291

readonly UIElement[]

UIContainerElement.children


get disabled(): boolean

Defined in: ui/src/UIButton.ts:525

boolean


get displayObject(): DisplayContainer

Defined in: ui/src/UIButton.ts:99

DisplayContainer

UIContainerElement.displayObject

UIElementBase.displayObject


get focusable(): boolean

Defined in: ui/src/UIButton.ts:287

Whether the button takes part in focus navigation.

boolean


get focused(): boolean

Defined in: ui/src/UIButton.ts:282

Whether the button holds focus in the scope that owns it.

boolean


get rotation(): number

Defined in: ui/src/UIElementBase.ts:50

See LayoutProps.rotation.

number

set rotation(value): void

Defined in: ui/src/UIElementBase.ts:54

number

void

UIElementBase.rotation


get scale(): Readonly<{ x: number; y: number; }>

Defined in: ui/src/UIElementBase.ts:41

See LayoutProps.scale.

Readonly<{ x: number; y: number; }>

set scale(value): void

Defined in: ui/src/UIElementBase.ts:45

number | { x: number; y: number; }

void

UIElementBase.scale


get transformOrigin(): Readonly<{ x: number; y: number; }>

Defined in: ui/src/UIElementBase.ts:32

See LayoutProps.transformOrigin.

Readonly<{ x: number; y: number; }>

set transformOrigin(value): void

Defined in: ui/src/UIElementBase.ts:36

number | { x: number; y: number; }

void

UIElementBase.transformOrigin


get visible(): boolean

Defined in: ui/src/UIButton.ts:529

boolean

set visible(v): void

Defined in: ui/src/UIButton.ts:533

boolean

void

UIContainerElement.visible

UIElementBase.visible


get zIndex(): number

Defined in: ui/src/UIElementBase.ts:59

See LayoutProps.zIndex.

number

set zIndex(value): void

Defined in: ui/src/UIElementBase.ts:63

number

void

UIElementBase.zIndex

_attachToTree(context): void

Defined in: ui/src/UIButton.ts:342

Internal

Stamped by UISurface from the owning entity and passed down the tree.

UITreeContext

void

UIContainerElement._attachToTree


_detachFromTree(): void

Defined in: ui/src/UIButton.ts:349

Internal

void

UIContainerElement._detachFromTree


_inspectState(): object

Defined in: ui/src/UIButton.ts:628

Internal

object

disabled: boolean

focusable: boolean

focused: boolean

hovered: boolean

pressed: boolean


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.

void


addElement(child): void

Defined in: ui/src/UIButton.ts:295

UIElement

void

UIContainerElement.addElement


applyLayout(): void

Defined in: ui/src/UIButton.ts:356

Apply Yoga-computed positions to children and resize background.

void

UIContainerElement.applyLayout


protected applyTransformProps(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.

LayoutProps

void

UIElementBase.applyTransformProps


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).

void

UIContainerElement.destroy

UIElementBase.destroy


insertElementBefore(child, before): void

Defined in: ui/src/UIButton.ts:324

UIElement

UIElement

void

UIContainerElement.insertElementBefore


removeElement(child): void

Defined in: ui/src/UIButton.ts:308

UIElement

void

UIContainerElement.removeElement


setDisabled(v): void

Defined in: ui/src/UIButton.ts:510

boolean

void


setText(s): void

Defined in: ui/src/UIButton.ts:499

string

void


update(p): void

Defined in: ui/src/UIButton.ts:538

Partial<UIButtonProps>

void

UIContainerElement.update

UIElementBase.update

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.