> For the complete documentation index, see [llms.txt](https://docs.overdare.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.overdare.com/development/api-reference/classes/textbutton.md).

# TextButton

TextButton : `GuiButton`

## Overview

TextButton displays text just like TextLabel, but it adds interactable buttons. In other words, it is a UI element that displays text as well as uses the events of GuiButton like click and tap.

TextButton can be controlled only in **client environment**.

## Properties

### ContentText

`string`

A read-only property that indicates the text of Text without formatting tags.

If RichText is true, it is the string with formatting tags removed from Text, and if false, it is the same as Text.

#### Code Samples

```lua
local ScreenGui = script.Parent
local TextButton = ScreenGui:WaitForChild("TextButton")

TextButton.RichText = true
TextButton.Text = "<b>Bold</b> text"
print(TextButton.ContentText)
```

### FontFace

`Font`

Specifies the font applied to the text displayed in the TextButton.

The font family, the thickness, and the italic style are specified together as a single value. The default value is the default font with the Regular thickness.

#### Code Samples

```lua
local ScreenGui = script.Parent
local TextButton = ScreenGui:WaitForChild("TextButton")

TextButton.FontFace = Font.fromName("Fredoka", Enum.FontWeight.Bold, Enum.FontStyle.Normal)
```

### LineHeight

`number`

Specifies the line spacing scale of multi-line text.

The default is 1, and the larger the value, the wider the spacing between lines.

#### Code Samples

```lua
local ScreenGui = script.Parent
local TextButton = ScreenGui:WaitForChild("TextButton")

TextButton.LineHeight = 1.5
```

### LocalizedText

`string`

A read-only property that returns the automatically translated result string based on the current client's locale.

Use this property to check the translated result actually displayed on the button when the original string assigned to the Text property is translated.

Automatic translation is applied only when the AutoLocalize property is true.

#### Code Samples

```lua
local ScreenGui = script.Parent
local TextButton = ScreenGui:WaitForChild("TextButton")

print(TextButton.LocalizedText)
```

### MaxVisibleGraphemes

`number`

Specifies how many characters of the text to display from the beginning.

The default, -1, displays the entire text. By increasing the value one by one from 0, you can create an effect where the text appears one character at a time.

#### Code Samples

```lua
local ScreenGui = script.Parent
local TextButton = ScreenGui:WaitForChild("TextButton")

TextButton.Text = "Welcome to OVERDARE"
for count = 0, #TextButton.Text do
    TextButton.MaxVisibleGraphemes = count
    task.wait(0.05)
end
TextButton.MaxVisibleGraphemes = -1
```

### RichText

`boolean`

Specifies whether to interpret formatting tags included in Text and apply formatting such as boldness or color to parts of the text.

If false, the tags are displayed as literal characters. The actual displayed text excluding the tags can be checked with ContentText.

#### Code Samples

```lua
local ScreenGui = script.Parent
local TextButton = ScreenGui:WaitForChild("TextButton")

TextButton.RichText = true
TextButton.Text = "<b>Bold</b> and <font color=\"#FF0000\">red</font>"
```

### Text

`string`

Specifies the text value to be displayed in TextButton.

Text is visually expressed by a variety of properties including color, transparency, size, font, alignment, and others.

In editor (Properties window), Shift + Enter can be used to input line break; in script, the character can be used to apply linefeed.

In addition, unlike TextLabel, user cannot break line with Shift + Enter in editor (Properties window). If line break is needed, user must use the character to apply linefeed.

#### Code Samples

```lua
local ScreenGui = script.Parent
local TextButton = ScreenGui:WaitForChild("TextButton")

TextButton.Text = "Hello"
```

### TextBounds

`Vector2`

A read-only property that indicates, in pixels, the size required to display the entire text with the current settings.

It is updated when properties that affect text layout, such as TextSize, LineHeight, and TextWrapped, change.

#### Code Samples

```lua
local ScreenGui = script.Parent
local TextButton = ScreenGui:WaitForChild("TextButton")

print("TextBounds : ", TextButton.TextBounds)
```

### TextColor3

`Color3`

Specifies the color to be applied to text.

#### Code Samples

```lua
local ScreenGui = script.Parent
local TextButton = ScreenGui:WaitForChild("TextButton")

TextButton.TextColor3 = Color3.new(255, 0, 0)
```

### TextDirection

`Enum.TextDirection`

Specifies the reading direction of the text.

* `Auto`: Determines the direction automatically.
* `LeftToRight`: Displays from left to right.
* `RightToLeft`: Displays from right to left.

#### Code Samples

```lua
local ScreenGui = script.Parent
local TextButton = ScreenGui:WaitForChild("TextButton")

TextButton.TextDirection = Enum.TextDirection.LeftToRight
```

### TextFits

`boolean`

A read-only property that indicates whether the text fits entirely within the area of the UI element.

It is false if the text exceeds the area. It can be used to decide whether to shorten the overflowing part with TextTruncate or to enlarge the area with AutomaticSize.

#### Code Samples

```lua
local ScreenGui = script.Parent
local TextButton = ScreenGui:WaitForChild("TextButton")

if not TextButton.TextFits then
    TextButton.TextTruncate = Enum.TextTruncate.AtEnd
end
```

### TextScaled

`boolean`

Determines whether text size is automatically adjusted to fill the entire area of TextButton.

When this feature is used, the TextSize value is ignored and TextWrapped will automatically be enabled.

#### Code Samples

```lua
local ScreenGui = script.Parent
local TextButton = ScreenGui:WaitForChild("TextButton")

TextButton.TextScaled = true
```

### TextSize

`number`

Controls text size in pixels; a higher value makes text displayed bigger.

#### Code Samples

```lua
local ScreenGui = script.Parent
local TextButton = ScreenGui:WaitForChild("TextButton")

TextButton.TextSize = 50
```

### TextStrokeColor3

`Color3`

Specifies the color of the text stroke.

The stroke is displayed when TextStrokeTransparency is less than 1.

#### Code Samples

```lua
local ScreenGui = script.Parent
local TextButton = ScreenGui:WaitForChild("TextButton")

TextButton.TextStrokeColor3 = Color3.fromRGB(255, 0, 0)
TextButton.TextStrokeTransparency = 0
```

### TextStrokeTransparency

`number`

Specifies the transparency of the text stroke.

0 means fully opaque, and 1 means the stroke is not visible. The default is 1.

#### Code Samples

```lua
local ScreenGui = script.Parent
local TextButton = ScreenGui:WaitForChild("TextButton")

TextButton.TextStrokeTransparency = 0.5
```

### TextTransparency

`number`

Specifies the transparency of text.

0 means the text is completely opaque while 1 means the text is totally invisible.

If background needs to be hidden while text is displayed, set BackgroundTransparency to 1.

#### Code Samples

```lua
local ScreenGui = script.Parent
local TextButton = ScreenGui:WaitForChild("TextButton")

TextButton.TextTransparency = 0.5
```

### TextTruncate

`Enum.TextTruncate`

Specifies how to shorten the overflowing part when the text exceeds the area of the UI element.

* `None`: Does not shorten the text.
* `AtEnd`: Cuts off the part that exceeds the area by word and displays an ellipsis (...) at the end.
* `SplitWord`: Cuts off even in the middle of a word and displays an ellipsis (...) at the end.

#### Code Samples

```lua
local ScreenGui = script.Parent
local TextButton = ScreenGui:WaitForChild("TextButton")

TextButton.TextTruncate = Enum.TextTruncate.AtEnd
```

### TextWrapped

`boolean`

Specifies whether the text in TextButton to automatically break line in order to stay in the text area.

If this property is set true, a long sentence is divided into several lines to fit in TextButton. Line break will be processed based on blank character.

#### Code Samples

```lua
local ScreenGui = script.Parent
local TextButton = ScreenGui:WaitForChild("TextButton")

TextButton.TextWrapped = true
```

### TextXAlignment

`Enum.TextXAlignment`

Specifies whether text is placed the left, center, or right section of the TextButton area.

#### Code Samples

```lua
local ScreenGui = script.Parent
local TextButton = ScreenGui:WaitForChild("TextButton")

TextButton.TextXAlignment = Enum.TextXAlignment.Left
```

### TextYAlignment

`Enum.TextYAlignment`

Specifies whether text is placed the top, center, or bottom section of the TextButton area.

#### Code Samples

```lua
local ScreenGui = script.Parent
local TextButton = ScreenGui:WaitForChild("TextButton")

TextButton.TextYAlignment = Enum.TextYAlignment.Top
```

## Methods

## Events

## See also

{% content-ref url="/pages/MseZiBAVju4q6L9qaBVQ" %}
[Font](/development/api-reference/datatype/font.md)
{% endcontent-ref %}

{% content-ref url="/pages/G4OKpyXzJeYFB71XwbDo" %}
[FontStyle](/development/api-reference/enums/fontstyle.md)
{% endcontent-ref %}

{% content-ref url="/pages/CgXuY71GWU7YzsLvFAmO" %}
[FontWeight](/development/api-reference/enums/fontweight.md)
{% endcontent-ref %}
