TextBox
Lets a user enter text. Use TextChanged to read the latest text; selection and input-method composition are also available.
Create: Instance.new("TextBox", {...}). Inherits: GuiObject.
Parent and children: Use Window, Frame or ScrollingFrame as the Parent. It does not accept visual child content.
Example
Section titled “Example”Where to put it: replace Src/Main.luau in a project created with this SDK. This is the complete entry file.
local Window = Instance.new("Window", { Title = "LUI example", Size = UDim2.fromOffset(560, 280),})local Status = Instance.new("TextLabel", { Parent = Window, Text = "Ready", Position = UDim2.fromOffset(16, 170), Size = UDim2.new(1, -32, 0, 72),})local Input = Instance.new("TextBox", { Parent = Window, PlaceholderText = "Enter a name", MaxLength = 80, Position = UDim2.fromOffset(16, 16), Size = UDim2.fromOffset(320, 44), AccessibilityLabel = "Name",})Input.TextChanged:Connect(function() Status.Text = "Name: " .. Input.Textend)Window.Visible = trueExpected result: Typing updates the status from committed text. The callback reads Input.Text; it does not receive the new string as an argument.
Behavior and limits
Section titled “Behavior and limits”- Selection counts Unicode scalars (code points), starting at zero. A visible character can contain more than one scalar.
- Input-method composition is temporary text, separate from committed Text. Secret input does not expose selection/composition and cannot be multiline.
Properties
Section titled “Properties”Committed text, excluding an active input-method preview. The normal TextBox ceiling is 65,534 UTF-8 bytes.
Type: string. Default: empty string. Read/write field.
Enabled
Section titled “Enabled”Whether the user can edit the field.
Type: boolean. Default: true. Read/write field.
Multiline
Section titled “Multiline”Allows multiple lines. It cannot be combined with Secret.
Type: boolean. Default: false. Read/write field.
Secret
Section titled “Secret”Requests secret-entry behavior and sticky sensitive classification. It does not provide encrypted storage.
Type: boolean. Default: false; implies sticky sensitivity. Read/write field.
PlaceholderText
Section titled “PlaceholderText”A prompt shown while the field is empty. Keep a persistent label when users need to identify the field after typing.
Type: string. Default: empty string. Read/write field.
MaxLength
Section titled “MaxLength”Maximum Unicode scalar count, within the control’s UTF-8 byte ceiling. A scalar is a Unicode code point; it is not necessarily one visible character.
Type: number. Default: 65534 Unicode scalars; UTF-8 byte ceiling also 65534. Read/write field.
SelectionStart
Section titled “SelectionStart”Zero-based Unicode scalar offset where the selection begins. It is not a UTF-8 byte or UTF-16 offset.
Type: number. Default: 0; Unicode scalar offset. Read/write field.
SelectionLength
Section titled “SelectionLength”Number of selected Unicode scalars. Zero is a caret with no selected text.
Type: number. Default: 0; Unicode scalar count. Read/write field.
IsComposing
Section titled “IsComposing”Whether an input method is currently composing text before committing it. Avoid replacing the field during composition.
Type: boolean. Default: false. Read-only.
CompositionText
Section titled “CompositionText”The current input-method preview text, separate from Text. Secret fields do not expose public preedit/selection data.
Type: string. Default: empty string. Read-only.
Signals
Section titled “Signals”TextChanged
Section titled “TextChanged”Fires when committed Text changes. No new-text argument is passed: read Input.Text inside the callback.
Type: Signal. Subscribe with :Connect(function(...) ... end).
SelectionChanged
Section titled “SelectionChanged”Fires when the selection changes. Read SelectionStart and SelectionLength; no payload is passed.
Type: Signal. Subscribe with :Connect(function(...) ... end).
CompositionStarted
Section titled “CompositionStarted”Fires when input-method composition begins. No arguments are passed.
Type: Signal. Subscribe with :Connect(function(...) ... end).
CompositionChanged
Section titled “CompositionChanged”Fires when the separate composition preview changes. Read CompositionText; no payload is passed.
Type: Signal. Subscribe with :Connect(function(...) ... end).
CompositionEnded
Section titled “CompositionEnded”Fires when composition ends. Read committed Text for the resulting field contents; no payload is passed.
Type: Signal. Subscribe with :Connect(function(...) ... end).
Inherited members
Section titled “Inherited members”You can use these directly on TextBox. Follow a member link for its explanation and example.
From GuiObject
Section titled “From GuiObject”Visible · AccessibilityLabel · AccessibilityDescription · Size · Position · AnchorPoint · LayoutOrder · BackgroundColor3 · BackgroundTransparency · BorderColor3 · BorderSizePixel · CornerRadius · Opacity · TextColor3 · TextSize · FontFamily · FontWeight · TextWrapped · TextXAlignment · TextYAlignment · ZIndex · ClipsDescendants · IsFocused · AbsolutePosition · AbsoluteSize · Focus · Focused · FocusLost · MouseEnter · MouseLeave · InputBegan · InputChanged · InputEnded
From Instance
Section titled “From Instance”Name · Sensitive · EffectiveSensitive · Parent · ClassName · Destroy · Clone · GetChildren · GetDescendants · FindFirstChild · IsA · Changed · Destroying
Full type declaration — for type checking and deeper reference
The declaration is generated from the SDK. Self is supplied by a colon call; read means the field cannot be assigned. See how to read this reference.
export type TextBox = GuiObject & { Text: string, Enabled: boolean, Multiline: boolean, Secret: boolean, PlaceholderText: string, MaxLength: number, SelectionStart: number, SelectionLength: number, read IsComposing: boolean, read CompositionText: string, read TextChanged: Signal, read SelectionChanged: Signal, read CompositionStarted: Signal, read CompositionChanged: Signal, read CompositionEnded: Signal,}Availability and deeper reading
Section titled “Availability and deeper reading”See platform limits before relying on host-specific behavior. The framework design specification and reflection/type sources are deeper engineering references, not extra setup required to build an app.