# TextBox

Roblox Engine API class from Roblox Studio 0.744.0.7441077 (version-7aaa6838d36c4448).

- Inherits from, nearest first: [GuiObject](https://rapi.sleaze.dev/classes/GuiObject.md), [GuiBase2d](https://rapi.sleaze.dev/classes/GuiBase2d.md), [GuiBase](https://rapi.sleaze.dev/classes/GuiBase.md), [Instance](https://rapi.sleaze.dev/classes/Instance.md), [Object](https://rapi.sleaze.dev/classes/Object.md)
- Memory category: Gui
- HTML page: https://rapi.sleaze.dev/classes/TextBox/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/TextBox

A 2D user interface element that displays player-editable text.

## Properties

### ClearTextOnFocus

```luau
TextBox.ClearTextOnFocus: boolean = true
```

- Tags: Read capabilities: UI

Determines whether clicking on the [`TextBox`](https://rapi.sleaze.dev/classes/TextBox.md) will clear its [`TextBox.Text`](https://rapi.sleaze.dev/classes/TextBox.md) property.

### Confidential

```luau
TextBox.Confidential: boolean = false
```

- Tags: Hidden, Not replicated, Not scriptable, Roblox engine security, Read capabilities: UI

### CursorPosition

```luau
TextBox.CursorPosition: number = 1
```

- Tags: Read capabilities: UI

Determines the offset of the text cursor in bytes, or `-1` if there is no cursor.

### HasFocus

```luau
TextBox.HasFocus: boolean = false
```

- Tags: Hidden, Not scriptable, Read only, Roblox engine security, Read capabilities: UI

### ManualFocusRelease

```luau
TextBox.ManualFocusRelease: boolean = false
```

- Tags: Hidden, Not replicated, Roblox script security, Read capabilities: UI

### MultiLine

```luau
TextBox.MultiLine: boolean = false
```

- Tags: Read capabilities: UI

When set to `true`, text inside a [`TextBox`](https://rapi.sleaze.dev/classes/TextBox.md) is able to move onto multiple lines.

### OverlayNativeInput

```luau
TextBox.OverlayNativeInput: boolean = false
```

- Tags: Hidden, Not replicated, Roblox script security, Read capabilities: UI

### ReturnKeyType

```luau
TextBox.ReturnKeyType: Enum.ReturnKeyType = Enum.ReturnKeyType.Default
```

- Tags: Hidden, Not replicated, Roblox script security, Read capabilities: UI

### SelectionStart

```luau
TextBox.SelectionStart: number = -1
```

- Tags: Read capabilities: UI

Determines the starting position of a text selection.

### ShouldEmitReturnEvents

```luau
TextBox.ShouldEmitReturnEvents: boolean = false
```

- Tags: Hidden, Not replicated, Roblox script security, Read capabilities: UI

### ShouldEmitTabEvents

```luau
TextBox.ShouldEmitTabEvents: boolean = false
```

- Tags: Hidden, Not replicated, Roblox script security, Read capabilities: UI

### ShouldEmitUpAndDownArrowEvents

```luau
TextBox.ShouldEmitUpAndDownArrowEvents: boolean = false
```

- Tags: Hidden, Not replicated, Roblox script security, Read capabilities: UI

### ShowNativeInput

```luau
TextBox.ShowNativeInput: boolean = true
```

- Tags: Read capabilities: UI

If set to `true`, input native to the platform is used instead of Roblox's built-in keyboard.

### TextEditable

```luau
TextBox.TextEditable: boolean = true
```

- Tags: Read capabilities: UI

Determines whether the player can change the [`Text`](https://rapi.sleaze.dev/classes/TextBox.md).

### TextInputType

```luau
TextBox.TextInputType: Enum.TextInputType = Enum.TextInputType.Default
```

- Tags: Hidden, Not replicated, Roblox script security, Read capabilities: UI

### ContentText

```luau
TextBox.ContentText: string = "TextBox"
```

- Tags: Read only, Read capabilities: UI

A copy of [`TextBox.Text`](https://rapi.sleaze.dev/classes/TextBox.md) that contains exactly what is being rendered by the [`TextBox`](https://rapi.sleaze.dev/classes/TextBox.md).

### Font

```luau
TextBox.Font: Enum.Font = Enum.Font.Legacy
```

- Tags: Hidden, Not replicated, Read capabilities: UI, Load only

Determines the font used to render text.

### FontFace

```luau
TextBox.FontFace: Font
```

- Tags: Read capabilities: UI

Determines the font face used to render text.

### LineHeight

```luau
TextBox.LineHeight: number = 1
```

- Tags: Read capabilities: UI

Scales the spacing between lines of text in the [`TextBox`](https://rapi.sleaze.dev/classes/TextBox.md).

### LocalizationMatchedSourceText

```luau
TextBox.LocalizationMatchedSourceText: string = ""
```

- Tags: Hidden, Not replicated, Roblox script security, Read capabilities: UI

### LocalizationMatchIdentifier

```luau
TextBox.LocalizationMatchIdentifier: string = ""
```

- Tags: Hidden, Not replicated, Roblox script security, Read capabilities: UI

### LocalizedPlaceholderText

```luau
TextBox.LocalizedPlaceholderText: string = ""
```

- Tags: Hidden, Not scriptable, Read only, Roblox engine security, Read capabilities: UI

### MaxVisibleGraphemes

```luau
TextBox.MaxVisibleGraphemes: number = -1
```

- Tags: Read capabilities: UI

The maximum number of graphemes the [`TextBox`](https://rapi.sleaze.dev/classes/TextBox.md) can show.

### OpenTypeFeatures

```luau
TextBox.OpenTypeFeatures: string = ""
```

- Tags: Read capabilities: UI

Applies OpenType typographic features to the text rendered by the [`TextBox`](https://rapi.sleaze.dev/classes/TextBox.md).

### OpenTypeFeaturesError

```luau
TextBox.OpenTypeFeaturesError: string = ""
```

- Tags: Read only, Read capabilities: UI, Save only

Read-only property that describes why the [`TextBox.OpenTypeFeatures`](https://rapi.sleaze.dev/classes/TextBox.md) string could not be applied.

### PlaceholderColor3

```luau
TextBox.PlaceholderColor3: Color3 = Color3.new(0.5, 0.5, 0.5)
```

- Tags: Read capabilities: UI

Sets the text color that gets used when no text has been entered into the [`TextBox`](https://rapi.sleaze.dev/classes/TextBox.md).

### PlaceholderText

```luau
TextBox.PlaceholderText: string = ""
```

- Tags: Read capabilities: UI

Sets the text that gets displayed when no text has been entered into the [`TextBox`](https://rapi.sleaze.dev/classes/TextBox.md).

### RichText

```luau
TextBox.RichText: boolean = false
```

- Tags: Read capabilities: UI

Determines whether the [`TextBox`](https://rapi.sleaze.dev/classes/TextBox.md) renders the [`Text`](https://rapi.sleaze.dev/classes/TextBox.md) string using rich text formatting.

### Text

```luau
TextBox.Text: string = "TextBox"
```

- Tags: Read capabilities: UI

Determines the string rendered by the [`TextBox`](https://rapi.sleaze.dev/classes/TextBox.md) element.

### TextBounds

```luau
TextBox.TextBounds: Vector2 = Vector2.zero
```

- Tags: Read only, Read capabilities: UI

The size of a [`TextBox`](https://rapi.sleaze.dev/classes/TextBox.md) element's text in offsets.

### TextColor3

```luau
TextBox.TextColor3: Color3 = Color3.new(0.105882, 0.164706, 0.207843)
```

- Tags: Read capabilities: UI

Determines the color of non-placeholder rendered text.

### TextDirection

```luau
TextBox.TextDirection: Enum.TextDirection = Enum.TextDirection.Auto
```

- Tags: Read capabilities: UI

Direction in which the text is rendered.

### TextFits

```luau
TextBox.TextFits: boolean = false
```

- Tags: Read only, Read capabilities: UI

Whether the text fits within the constraints of the [`TextBox`](https://rapi.sleaze.dev/classes/TextBox.md).

### TextScaled

```luau
TextBox.TextScaled: boolean = false
```

- Tags: Read capabilities: UI

Changes whether text is resized to fit within the [`TextBox`](https://rapi.sleaze.dev/classes/TextBox.md).

### TextSize

```luau
TextBox.TextSize: number = 8
```

- Tags: Read capabilities: UI

Determine the line height of text in offsets.

### TextStrokeColor3

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

- Tags: Read capabilities: UI

Determines the color of the text stroke (outline).

### TextStrokeTransparency

```luau
TextBox.TextStrokeTransparency: number = 1
```

- Tags: Read capabilities: UI

Determines the transparency of the text stroke (outline).

### TextTransparency

```luau
TextBox.TextTransparency: number = 0
```

- Tags: Read capabilities: UI

Determines the transparency of the rendered text.

### TextTruncate

```luau
TextBox.TextTruncate: Enum.TextTruncate = Enum.TextTruncate.None
```

- Tags: Read capabilities: UI

Controls the truncation of the text displayed in the [`TextBox`](https://rapi.sleaze.dev/classes/TextBox.md).

### TextWrapped

```luau
TextBox.TextWrapped: boolean = false
```

- Tags: Read capabilities: UI

Determines if text wraps to multiple lines within the [`TextBox`](https://rapi.sleaze.dev/classes/TextBox.md) element space, truncating excess text.

### TextXAlignment

```luau
TextBox.TextXAlignment: Enum.TextXAlignment = Enum.TextXAlignment.Center
```

- Tags: Read capabilities: UI

Determines the horizontal alignment of the rendered text.

### TextYAlignment

```luau
TextBox.TextYAlignment: Enum.TextYAlignment = Enum.TextYAlignment.Center
```

- Tags: Read capabilities: UI

Determines the vertical alignment of the rendered text.

### FontSize

```luau
TextBox.FontSize: Enum.FontSize = Enum.FontSize.Size8
```

- Tags: Deprecated, Not replicated, Read capabilities: UI, Load only
- Use instead: [`TextBox.TextSize`](https://rapi.sleaze.dev/classes/TextBox.md)

**Deprecated:** This item has been superseded by [`TextBox.TextSize`](https://rapi.sleaze.dev/classes/TextBox.md) which should be used in all new work.

Determines the font size of a [`TextBox`](https://rapi.sleaze.dev/classes/TextBox.md) object.

### TextColor

```luau
TextBox.TextColor: BrickColor
```

- Tags: Deprecated, Hidden, Not replicated, Read capabilities: UI, Load only

**Deprecated:** This item has been superseded by [`TextBox.TextColor3`](https://rapi.sleaze.dev/classes/TextBox.md) which should be used in all new work.

### TextWrap

```luau
TextBox.TextWrap: boolean = false
```

- Tags: Deprecated, Not replicated, Read capabilities: UI, Load only
- Use instead: [`TextBox.TextWrapped`](https://rapi.sleaze.dev/classes/TextBox.md)

**Deprecated:** This item has been superseded by [`TextBox.TextWrapped`](https://rapi.sleaze.dev/classes/TextBox.md) which should be used in all new work.

## Methods

### CaptureFocus

```luau
TextBox:CaptureFocus()
```

- Tags: Capabilities: UI

Forces the client to focus on the [`TextBox`](https://rapi.sleaze.dev/classes/TextBox.md).

### IsFocused

```luau
TextBox:IsFocused(): boolean
```

- Tags: Capabilities: UI

Whether the TextBox currently has focus.

Returns: Returns `true` if the [`TextBox`](https://rapi.sleaze.dev/classes/TextBox.md) is focused or `false` if it is not.

### ReleaseFocus

```luau
TextBox:ReleaseFocus(submitted: boolean? = false)
```

- Tags: Capabilities: UI

Forces the client to unfocus the TextBox.

Parameters:

- `submitted`: Whether the [`TextBox.FocusLost`](https://rapi.sleaze.dev/classes/TextBox.md) event's `enterPressed` parameter reports `true`, as if the player pressed Enter to submit text. Defaults to `false`.

### ResetKeyboardMode

```luau
TextBox:ResetKeyboardMode()
```

- Tags: Roblox script security, Capabilities: UI

### SetTextFromInput

```luau
TextBox:SetTextFromInput(text: string)
```

- Tags: Roblox script security, Capabilities: UI

## Events

### Focused

```luau
TextBox.Focused: RBXScriptSignal<()>
```

- Tags: Capabilities: UI

Fires when the [`TextBox`](https://rapi.sleaze.dev/classes/TextBox.md) gains focus.

### FocusLost

```luau
TextBox.FocusLost: RBXScriptSignal<(enterPressed: boolean, inputThatCausedFocusLoss: InputObject)>
```

- Tags: Capabilities: UI

Fires when the [`TextBox`](https://rapi.sleaze.dev/classes/TextBox.md) loses its focus.

### ReturnPressedFromOnScreenKeyboard

```luau
TextBox.ReturnPressedFromOnScreenKeyboard: RBXScriptSignal<()>
```

- Tags: Capabilities: UI

Fires when the [`TextBox`](https://rapi.sleaze.dev/classes/TextBox.md) is focused and the player presses the on-screen keyboard's return/enter button.

## Inherited members

- From [GuiObject](https://rapi.sleaze.dev/classes/GuiObject.md): `SelectionImageObject`, `ClipsDescendants`, `Draggable`, `Active`, `AnchorPoint`, `AutomaticSize`, `BackgroundColor3`, `BackgroundTransparency`, `BorderColor3`, `BorderMode`, `BorderSizePixel`, `InputSink`, `Interactable`, `LayoutOrder`, `Position`, `Rotation`, `SelectionRect2D`, `Sink`, `Size`, `SizeConstraint`, `Visible`, `ZIndex`, `BackgroundColor`, `BorderColor`, `Transparency`, `DragBeginConnectionCount`, `DragStoppedConnectionCount`, `MouseEnterConnectionCount`, `MouseLeaveConnectionCount`, `MouseMovedConnectionCount`, `MouseWheelBackwardConnectionCount`, `MouseWheelForwardConnectionCount`, `NextSelectionDown`, `NextSelectionLeft`, `NextSelectionRight`, `NextSelectionUp`, `Selectable`, `SelectionOrder`, `GuiState`, `TweenPositionInternal`, `TweenSizeAndPositionInternal`, `TweenSizeInternal`, `TweenPosition`, `TweenSize`, `TweenSizeAndPosition`, `InputBegan`, `InputChanged`, `InputEnded`, `MouseEnter`, `MouseLeave`, `MouseMoved`, `MouseWheelBackward`, `MouseWheelForward`, `SelectionGained`, `SelectionLost`, `TouchLongPress`, `TouchPan`, `TouchPinch`, `TouchRotate`, `TouchSwipe`, `TouchTap`, `DragBegin`, `DragStopped`
- From [GuiBase2d](https://rapi.sleaze.dev/classes/GuiBase2d.md): `AbsolutePosition`, `AbsoluteRotation`, `AbsoluteSize`, `ActiveQueryNames`, `ReplicatedInsertionOrder`, `ClippedRect`, `IsNotOccluded`, `RawRect2D`, `TotalGroupScale`, `AutoLocalize`, `RootLocalizationTable`, `Localize`, `SelectionBehaviorDown`, `SelectionBehaviorLeft`, `SelectionBehaviorRight`, `SelectionBehaviorUp`, `SelectionGroup`, `SelectionChanged`
- From [Instance](https://rapi.sleaze.dev/classes/Instance.md): `Archivable`, `archivable`, `Attributes`, `AttributesReplicate`, `AttributesSerialize`, `HistoryId`, `Name`, `Parent`, `PredictionMode`, `PropertyStatusStudio`, `RobloxLocked`, `SerializedOverrides`, `SourceAssetId`, `Tags`, `UniqueId`, `numExpectedDirectChildren`, `DataCost`, `Capabilities`, `DefinesCapabilities`, `IsInSandbox`, `Sandboxed`, `AddTag`, `ClearAllChildren`, `Clone`, `Destroy`, `FindFirstAncestor`, `FindFirstAncestorOfClass`, `FindFirstAncestorWhichIsA`, `FindFirstChild`, `FindFirstChildOfClass`, `FindFirstChildWhichIsA`, `FindFirstDescendant`, `GetActor`, `GetAttribute`, `GetAttributeChangedSignal`, `GetAttributes`, `GetChildren`, `GetDebugId`, `GetDescendants`, `GetFullName`, `GetStyled`, `GetStyledPropertyChangedSignal`, `GetTags`, `HasTag`, `IsAncestorOf`, `IsDescendantOf`, `IsPropertyModified`, `QueryDescendants`, `RemoveTag`, `ResetPropertyToDefault`, `SetAttribute`, `WaitForChild`, `Remove`, `children`, `clone`, `destroy`, `findFirstChild`, `getChildren`, `isDescendantOf`, `remove`, `AncestryChanged`, `AttributeChanged`, `ChildAdded`, `ChildRemoved`, `DescendantAdded`, `DescendantRemoving`, `Destroying`, `StyledPropertiesChanged`, `childAdded`
- From [Object](https://rapi.sleaze.dev/classes/Object.md): `ClassName`, `className`, `GetPropertyChangedSignal`, `IsA`, `isA`, `Changed`
