Open Asterune
TextBox

TextBox

An editable text field in a GUI.

Creatable
Instance.new("TextBox")
Inherits
GuiObjectGuiBase2dGuiBaseInstance
Replication
Standard

Behavior

TextBox accepts text input and exposes the shared GUI text-layout properties. Use its focus events to react to editing state.

Summary

Members84
Properties67
Methods3
Events14

Properties

AbsolutePosition

TextBox.AbsolutePosition: Vector2 = Vector2.new(0, 0)

The resolved top-left position of this interface element in pixels.

AbsoluteRotation

TextBox.AbsoluteRotation: number = 0

The resolved rotation of this interface element in degrees, including ancestor rotation.

AbsoluteSize

TextBox.AbsoluteSize: Vector2 = Vector2.new(0, 0)

The resolved width and height of this interface element in pixels.

Active

TextBox.Active: boolean = true

Whether this interface accepts and consumes input.

AnchorPoint

TextBox.AnchorPoint: Vector2 = Vector2.new(0, 0)

The normalized point within the element used as the origin for Position. (0, 0) is the top-left corner; (0.5, 0.5) is the center.

AutomaticSize

The dimensions that resize to fit the element's content.

BackgroundColor3

TextBox.BackgroundColor3: Color3 = Color3.new(0.6392157, 0.63529414, 0.64705884)

The color used to fill the element's background.

BackgroundTransparency

TextBox.BackgroundTransparency: number = 0

The background transparency, from 0 for opaque to 1 for invisible.

BorderColor3

TextBox.BorderColor3: Color3 = Color3.new(0.105882354, 0.16470589, 0.20784314)

The color of the element's border.

BorderMode

Whether the border is drawn outside, across, or inside the element's bounds.

BorderSizePixel

TextBox.BorderSizePixel: number = 1

The border thickness in pixels.

ClearTextOnFocus

TextBox.ClearTextOnFocus: boolean = true

Whether the text is cleared when the TextBox gains focus.

ClipsDescendants

TextBox.ClipsDescendants: boolean = false

Whether descendant rendering is clipped to this element's bounds.

ContentText

TextBox.ContentText: string

The text content after rich-text markup has been removed. Read-only.

CornerRadius

TextBox.CornerRadius: number = 0

The corner radius used for the element's rounded background.

Corners

TextBox.Corners: { number } = {}

The individual corner radii used for the element's rounded background.

CursorPosition

TextBox.CursorPosition: number

The text insertion position. A value of -1 indicates no active cursor.

Draggable

TextBox.Draggable: boolean = false

Whether pointer dragging can move the element.

FontFace

TextBox.FontFace: Font = ""

The typeface used to render the text.

FontMono

TextBox.FontMono: boolean

Whether the text uses the monospaced font option.

FontStyle

The style applied to the text.

FontWeight

The weight applied to the text.

Grow

TextBox.Grow: number = 0

The share of remaining main-axis space assigned to this child in flow layout.

GuiState

TextBox.GuiState: Enum.GuiState = Enum.GuiState.Idle

The element's current idle, hover, pressed, or non-interactable state.

InputSink

TextBox.InputSink: Enum.InputSink = Enum.InputSink.None

Which input events this element consumes before they reach elements behind it.

Interactable

TextBox.Interactable: boolean = true

Whether the element accepts interaction.

Layout

TextBox.Layout: Enum.Layout = Enum.Layout.Flow

Whether children use flow layout or their explicit positions.

LayoutOrder

TextBox.LayoutOrder: number = 0

The numeric order of this element when a parent layout sorts by layout order.

LetterSpacing

TextBox.LetterSpacing: number

The additional spacing between text glyphs.

LineHeight

TextBox.LineHeight: number

The line-height multiplier used for multi-line text.

MaxVisibleGraphemes

TextBox.MaxVisibleGraphemes: number

The maximum number of visible graphemes. A negative value shows all graphemes.

MultiLine

TextBox.MultiLine: boolean = false

Whether the TextBox accepts multiple lines of text.

NextSelectionDown

TextBox.NextSelectionDown: GuiObject? = nil

The interface element selected when navigating down from this element.

NextSelectionLeft

TextBox.NextSelectionLeft: GuiObject? = nil

The interface element selected when navigating left from this element.

NextSelectionRight

TextBox.NextSelectionRight: GuiObject? = nil

The interface element selected when navigating right from this element.

NextSelectionUp

TextBox.NextSelectionUp: GuiObject? = nil

The interface element selected when navigating up from this element.

Opacity

TextBox.Opacity: number = 1

The opacity multiplier applied to this element and its descendants.

Placeholder

TextBox.Placeholder: string

The text displayed while the TextBox is empty.

PlaceholderColor

TextBox.PlaceholderColor: Color3

The color used for the TextBox placeholder.

Position

TextBox.Position: UDim2 = UDim2.new(0, 0, 0, 0)

The element position relative to its parent. Scale components use the parent size; offsets are in pixels.

Pressed

TextBox.Pressed: AstScriptSignal<>

Fires when a text-input key is pressed.

Released

TextBox.Released: AstScriptSignal<>

Fires when a text-input key is released.

RichText

TextBox.RichText: boolean

Whether markup in the text is parsed and rendered as rich text.

Rotation

TextBox.Rotation: number = 0

The interface rotation in degrees.

Selectable

TextBox.Selectable: boolean = false

Whether interface navigation can select this element.

SelectedText

TextBox.SelectedText: string

The currently selected text.

SelectionImageObject

TextBox.SelectionImageObject: GuiObject? = nil

The interface element used to draw the selection indicator.

SelectionOrder

TextBox.SelectionOrder: number = 0

The numeric order used for interface selection traversal.

SelectionStart

TextBox.SelectionStart: number

The start of the text selection. A value of -1 indicates no selection.

Size

TextBox.Size: UDim2 = UDim2.new(0, 0, 0, 0)

The element size relative to its parent. Scale components use the parent size; offsets are in pixels.

SizeConstraint

The parent axes used to resolve relative interface size.

Text

TextBox.Text: string = ""

The text displayed by the element.

TextBounds

TextBox.TextBounds: Vector2

The resolved pixel bounds of the rendered text. Read-only.

TextColor3

TextBox.TextColor3: Color3 = Color3.new(0, 0, 0)

The color used to render text.

TextEditable

TextBox.TextEditable: boolean = true

Whether the user can edit the TextBox text.

TextFits

TextBox.TextFits: boolean

Whether the rendered text fits within the text box's bounds. Read-only.

TextScaled

TextBox.TextScaled: boolean

Whether the engine scales the text to fit the text box's bounds.

TextSize

TextBox.TextSize: number = 8

The base text size in pixels.

TextStrokeColor3

TextBox.TextStrokeColor3: Color3 = Color3.new(0, 0, 0)

The color used for the outline around text glyphs.

TextStrokeTransparency

TextBox.TextStrokeTransparency: number = 1

The transparency of the outline around text glyphs.

TextTransparency

TextBox.TextTransparency: number = 0

The text transparency, from 0 for opaque to 1 for invisible.

TextTruncate

TextBox.TextTruncate: EnumItem

The truncation mode used when text does not fit.

TextWrapped

TextBox.TextWrapped: boolean = false

Whether text wraps onto additional lines within the element's width.

TextXAlignment

The horizontal alignment of text within the element.

TextYAlignment

The vertical alignment of text within the element.

Visible

TextBox.Visible: boolean = true

Whether this interface element is rendered.

ZIndex

TextBox.ZIndex: number = 1

The element's draw-order index. Interpretation depends on the root's ZIndexBehavior.

Methods

CaptureFocus

TextBox:CaptureFocus(): ()

Gives keyboard focus to this interface element.

GetExecutionGroup

TextBox:GetExecutionGroup(): ExecutionGroup?

Returns this instance if it is an ExecutionGroup. Otherwise returns the nearest ancestor ExecutionGroup, or nil when no group contains the instance.

ReleaseFocus

TextBox:ReleaseFocus(): ()

Removes keyboard focus from this interface element.

Events

DragBegin

TextBox.DragBegin: RBXScriptSignal

Fires when pointer dragging of the element begins.

DragStopped

TextBox.DragStopped: RBXScriptSignal

Fires when pointer dragging of the element ends.

FocusLost

TextBox.FocusLost: RBXScriptSignal

Fires when the TextBox loses keyboard focus.

Focused

TextBox.Focused: RBXScriptSignal

Fires when the TextBox gains keyboard focus.

InputBegan

TextBox.InputBegan: RBXScriptSignal

Fires when input begins over or is dispatched to this interface element.

InputChanged

TextBox.InputChanged: RBXScriptSignal

Fires when input dispatched to this element changes.

InputEnded

TextBox.InputEnded: RBXScriptSignal

Fires when input dispatched to this element ends.

MouseWheelBackward

TextBox.MouseWheelBackward: RBXScriptSignal

Fires when the mouse wheel scrolls backward over this element.

MouseWheelForward

TextBox.MouseWheelForward: RBXScriptSignal

Fires when the mouse wheel scrolls forward over this element.

PointerEntered

TextBox.PointerEntered: RBXScriptSignal

Fires when a pointer moves onto the text box.

PointerExited

TextBox.PointerExited: RBXScriptSignal

Fires when a pointer moves off the text box.

PointerMoved

TextBox.PointerMoved: RBXScriptSignal

Fires when the pointer moves across the text box.

SelectionGained

TextBox.SelectionGained: RBXScriptSignal

Fires when interface navigation selects this element.

SelectionLost

TextBox.SelectionLost: RBXScriptSignal

Fires when this element loses interface selection.

Inherited members

Inherited48

Example

Luau
local nameBox = Instance.new("TextBox")
nameBox.Text = "Player name"
nameBox.Focused:Connect(function()
  print("editing")
end)

TextLabel · TextButton · InputService