Skip to content

Search documentation

Enter at least two characters.

    TextBox

    SDK 0.1.0-preview.2 · ExperimentalDownload & release notes ↗

    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.

    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.Text
    end)
    Window.Visible = true

    Expected result: Typing updates the status from committed text. The callback reads Input.Text; it does not receive the new string as an argument.

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

    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.

    Whether the user can edit the field.

    Type: boolean. Default: true. Read/write field.

    Allows multiple lines. It cannot be combined with Secret.

    Type: boolean. Default: false. Read/write field.

    Requests secret-entry behavior and sticky sensitive classification. It does not provide encrypted storage.

    Type: boolean. Default: false; implies sticky sensitivity. Read/write field.

    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.

    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.

    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.

    Number of selected Unicode scalars. Zero is a caret with no selected text.

    Type: number. Default: 0; Unicode scalar count. Read/write field.

    Whether an input method is currently composing text before committing it. Avoid replacing the field during composition.

    Type: boolean. Default: false. Read-only.

    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.

    Fires when committed Text changes. No new-text argument is passed: read Input.Text inside the callback.

    Type: Signal. Subscribe with :Connect(function(...) ... end).

    Fires when the selection changes. Read SelectionStart and SelectionLength; no payload is passed.

    Type: Signal. Subscribe with :Connect(function(...) ... end).

    Fires when input-method composition begins. No arguments are passed.

    Type: Signal. Subscribe with :Connect(function(...) ... end).

    Fires when the separate composition preview changes. Read CompositionText; no payload is passed.

    Type: Signal. Subscribe with :Connect(function(...) ... end).

    Fires when composition ends. Read committed Text for the resulting field contents; no payload is passed.

    Type: Signal. Subscribe with :Connect(function(...) ... end).

    You can use these directly on TextBox. Follow a member link for its explanation and example.

    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

    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,
    }

    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.