TextButton
A 2D user interface element that displays interactive text.
Memory category | Gui |
---|
Member index 30
Removed member index 1
History | Member | |
---|---|---|
466 | Content: string |
Description
A TextButton behaves similarly to TextLabel in regards to rendering, with the additional behaviors of a GuiButton.
You can disable text rendering by setting
TextTransparency to 1
. This will result
in a plain rectangle that can be used as a button.
History 112
- 629 Add OpenTypeFeaturesError
- 629 Add OpenTypeFeatures
- 605 Change Tags of from [Hidden, NotReplicated, NotScriptable] to [Hidden, NotReplicated]
- 605 Change WriteSecurity of from RobloxSecurity to RobloxScriptSecurity
- 605 Change ReadSecurity of from RobloxSecurity to RobloxScriptSecurity
- 605 Change Tags of from [Hidden, NotReplicated, NotScriptable] to [Hidden, NotReplicated]
- 605 Change ReadSecurity of from RobloxSecurity to RobloxScriptSecurity
- 605 Change WriteSecurity of from RobloxSecurity to RobloxScriptSecurity
- 603 Add
- 603 Add
- 581 Add TextDirection
- 573 Change ReturnType of SetTextFromInput from void to null
- 558 Change Tags of from [Hidden] to [Hidden, NotReplicated]
- 558 Change CanSave of from true to false
- 553 Change Default of TextYAlignment from to Center
- 553 Change Default of TextXAlignment from to Center
- 553 Change Default of TextWrapped from to false
- 553 Change Default of TextWrap from to false
- 553 Change PreferredDescriptor of TextWrap from to TextWrapped
- 553 Change Default of TextTruncate from to None
- 553 Change Default of TextTransparency from to 0
- 553 Change Default of TextStrokeTransparency from to 1
- 553 Change Default of TextStrokeColor3 from to Color3(0, 0, 0)
- 553 Change Default of TextSize from to 8
- 553 Change Default of TextScaled from to false
- 553 Change Default of TextFits from to false
- 553 Change Default of TextColor3 from to Color3(0.105882, 0.164706, 0.207843)
- 553 Change Default of from to
- 553 Change Default of TextBounds from to Vector2(0, 0)
- 553 Change Default of Text from to Button
- 553 Change Default of RichText from to false
- 553 Change Default of MaxVisibleGraphemes from to -1
- 553 Change Default of LineHeight from to 1
- 553 Change PreferredDescriptor of FontSize from to TextSize
- 553 Change Default of FontSize from to Size8
- 553 Change Default of FontFace from to
- 553 Change Default of from to Legacy
- 553 Change Default of ContentText from to Button
- 553 Add
- 549 Change Tags of from [] to [Hidden]
- 517 Add FontFace
- 501 Add ContentText
- 486 Change ThreadSafety of TextYAlignment from ReadOnly to ReadSafe
- 486 Change ThreadSafety of TextXAlignment from ReadOnly to ReadSafe
- 486 Change ThreadSafety of TextWrapped from ReadOnly to ReadSafe
- 486 Change ThreadSafety of TextWrap from ReadOnly to ReadSafe
- 486 Change ThreadSafety of TextTruncate from ReadOnly to ReadSafe
- 486 Change ThreadSafety of TextTransparency from ReadOnly to ReadSafe
- 486 Change ThreadSafety of TextStrokeTransparency from ReadOnly to ReadSafe
- 486 Change ThreadSafety of TextStrokeColor3 from ReadOnly to ReadSafe
- 486 Change ThreadSafety of TextSize from ReadOnly to ReadSafe
- 486 Change ThreadSafety of TextScaled from ReadOnly to ReadSafe
- 486 Change ThreadSafety of TextFits from ReadOnly to ReadSafe
- 486 Change ThreadSafety of TextColor3 from ReadOnly to ReadSafe
- 486 Change ThreadSafety of from ReadOnly to ReadSafe
- 486 Change ThreadSafety of TextBounds from ReadOnly to ReadSafe
- 486 Change ThreadSafety of Text from ReadOnly to ReadSafe
- 486 Change ThreadSafety of RichText from ReadOnly to ReadSafe
- 486 Change ThreadSafety of MaxVisibleGraphemes from ReadOnly to ReadSafe
- 486 Change ThreadSafety of from ReadOnly to ReadSafe
- 486 Change ThreadSafety of LineHeight from ReadOnly to ReadSafe
- 486 Change ThreadSafety of FontSize from ReadOnly to ReadSafe
- 486 Change ThreadSafety of from ReadOnly to ReadSafe
- 469 Add MaxVisibleGraphemes
- 466 Remove Content
- 465 Add Content
- 462 Change ThreadSafety of SetTextFromInput from to Unsafe
- 462 Change ThreadSafety of TextYAlignment from to ReadOnly
- 462 Change ThreadSafety of TextXAlignment from to ReadOnly
- 462 Change ThreadSafety of TextWrapped from to ReadOnly
- 462 Change ThreadSafety of TextWrap from to ReadOnly
- 462 Change ThreadSafety of TextTruncate from to ReadOnly
- 462 Change ThreadSafety of TextTransparency from to ReadOnly
- 462 Change ThreadSafety of TextStrokeTransparency from to ReadOnly
- 462 Change ThreadSafety of TextStrokeColor3 from to ReadOnly
- 462 Change ThreadSafety of TextSize from to ReadOnly
- 462 Change ThreadSafety of TextScaled from to ReadOnly
- 462 Change ThreadSafety of TextFits from to ReadOnly
- 462 Change ThreadSafety of TextColor3 from to ReadOnly
- 462 Change ThreadSafety of from to ReadOnly
- 462 Change ThreadSafety of TextBounds from to ReadOnly
- 462 Change ThreadSafety of Text from to ReadOnly
- 462 Change ThreadSafety of RichText from to ReadOnly
- 462 Change ThreadSafety of from to ReadOnly
- 462 Change ThreadSafety of LineHeight from to ReadOnly
- 462 Change ThreadSafety of FontSize from to ReadOnly
- 462 Change ThreadSafety of from to ReadOnly
- 438 Add RichText
- 326 Add TextTruncate
- 317 Add LineHeight
- 309 Add
- 290 Change Tags of FontSize from [NotReplicated] to [NotReplicated, Deprecated]
- 277 Add SetTextFromInput
- 263 Add TextSize
- 55 Change Tags of TextButton from [preliminary] to []
- 51 Add TextWrapped
- 51 Change Tags of TextWrap from [NotReplicated] to [NotReplicated, Deprecated]
- 50 Add TextScaled
- 48 Add TextStrokeTransparency
- 48 Add TextStrokeColor3
- 47 Add TextYAlignment
- 47 Add TextXAlignment
- 47 Add TextWrap
- 47 Add TextTransparency
- 47 Add TextFits
- 47 Add TextColor3
- 47 Add
- 47 Add TextBounds
- 47 Add Text
- 47 Add FontSize
- 47 Add
- 47 Add TextButton
Members 30
ContentText
Type | Default | |
---|---|---|
string | Button |
This property provides a copy of Text that contains exactly what is being rendered by the TextButton. This is useful for eliminating style tags used for rich text markup; for example, when RichText is enabled, the ContentText property shows the text as it appears to the user.
RichText | Text | ContentText |
---|---|---|
false | <b>Hello,<br/> world!</b> | <b>Hello,<br/> world!</b> |
true | <b>Hello,<br/> world!</b> | Hello, world! |
Thread safety | ReadSafe |
---|---|
Category | Text |
Loaded/Saved | false |
History 2
- 553 Change Default of ContentText from to Button
- 501 Add ContentText
FontFace
Type | Default | |
---|---|---|
Font |
This property is similar to the Font property but allows setting fonts that don't exist in Font.
This property is kept in sync with the Font property, such that when setting FontFace, the font is set to the corresponding Font value or to Font.Unknown if there are no matches.
Thread safety | ReadSafe |
---|---|
Category | Text |
Loaded/Saved | true |
FontSize
Type | Default | |
---|---|---|
FontSize | Size8 |
This property determines the font size to be used.
Thread safety | ReadSafe |
---|---|
Category | Text |
Loaded/Saved | true/false |
History 6
- 553 Change PreferredDescriptor of FontSize from to TextSize
- 553 Change Default of FontSize from to Size8
- 486 Change ThreadSafety of FontSize from ReadOnly to ReadSafe
- 462 Change ThreadSafety of FontSize from to ReadOnly
- 290 Change Tags of FontSize from [NotReplicated] to [NotReplicated, Deprecated]
- 47 Add FontSize
LineHeight
Type | Default | |
---|---|---|
float | 1 |
Controls the height of lines as a multiple of the font's em
square size
by scaling the spacing between lines of text in the TextButton.
Valid values range from 1.0
to 3.0
, defaulting to 1.0
.
Thread safety | ReadSafe |
---|---|
Category | Text |
Loaded/Saved | true |
History 4
- 553 Change Default of LineHeight from to 1
- 486 Change ThreadSafety of LineHeight from ReadOnly to ReadSafe
- 462 Change ThreadSafety of LineHeight from to ReadOnly
- 317 Add LineHeight
MaxVisibleGraphemes
Type | Default | |
---|---|---|
int | -1 |
This property controls the maximum number of graphemes (or units of text) that are shown on the TextButton. It is primarily provided as an easy way to create a typewriter effect where the characters appear one at a time.
Changing the property does not change the position or size of the visible graphemes; the layout will be calculated as if all graphemes are visible.
Setting the property to -1
disables the limit and shows the entirety of
the Text.
Thread safety | ReadSafe |
---|---|
Category | Text |
Loaded/Saved | true |
History 3
- 553 Change Default of MaxVisibleGraphemes from to -1
- 486 Change ThreadSafety of MaxVisibleGraphemes from ReadOnly to ReadSafe
- 469 Add MaxVisibleGraphemes
OpenTypeFeatures
Type | Default | |
---|---|---|
string |
Thread safety | ReadSafe |
---|---|
Category | Text |
Loaded/Saved | true |
History 1
- 629 Add OpenTypeFeatures
OpenTypeFeaturesError
Type | Default | |
---|---|---|
string |
Thread safety | ReadSafe |
---|---|
Category | Text |
Loaded/Saved | false/true |
History 1
RichText
Type | Default | |
---|---|---|
bool | false |
This property determines whether the TextButton renders its text using rich text markup to style sections of the string in bold, italics, specific colors, and more.
To use rich text, simply include rich text formatting tags in the Text string.
Thread safety | ReadSafe |
---|---|
Category | Text |
Loaded/Saved | true |
SetTextFromInput
Parameters (1) | ||
---|---|---|
text | string | |
Returns (1) | ||
null |
Security | RobloxScriptSecurity |
---|---|
Thread safety | Unsafe |
History 3
- 573 Change ReturnType of SetTextFromInput from void to null
- 462 Change ThreadSafety of SetTextFromInput from to Unsafe
- 277 Add SetTextFromInput
Text
Type | Default | |
---|---|---|
string | Button |
This property determines the text content rendered by the TextButton. The visual properties of the string rendered to the screen is determined by TextColor3, TextTransparency, TextSize, Font, TextScaled, TextWrapped, TextXAlignment and TextYAlignment.
It is possible to render emoji such as 🔒 and other symbols which aren't affected by the TextColor3 property. These can be pasted into Script and LocalScript objects, as well as the field within the Properties window.
This property may contain newline characters. Similarly, this property may contain a tab character, but it will render as a space instead.
Thread safety | ReadSafe |
---|---|
Category | Text |
Loaded/Saved | true |
TextBounds
Type | Default | |
---|---|---|
Vector2 | 0, 0 |
This read-only property reflects the absolute size of rendered text in offsets, meaning that if you try to fit text into a rectangle, this property would reflect the minimum dimensions of the rectangle you'd need in order to fit the text.
Using TextService:GetTextSize(), you can predict what TextBounds will be given a string, Font, TextSize, and frame size.
Thread safety | ReadSafe |
---|---|
Category | Text |
Loaded/Saved | false |
History 4
- 553 Change Default of TextBounds from to Vector2(0, 0)
- 486 Change ThreadSafety of TextBounds from ReadOnly to ReadSafe
- 462 Change ThreadSafety of TextBounds from to ReadOnly
- 47 Add TextBounds
TextColor3
Type | Default | |
---|---|---|
Color3 | 0.105882, 0.164706, 0.207843 |
This property determines the color of all the text rendered by the TextButton element.
Thread safety | ReadSafe |
---|---|
Category | Text |
Loaded/Saved | true |
History 4
- 553 Change Default of TextColor3 from to Color3(0.105882, 0.164706, 0.207843)
- 486 Change ThreadSafety of TextColor3 from ReadOnly to ReadSafe
- 462 Change ThreadSafety of TextColor3 from to ReadOnly
- 47 Add TextColor3
TextDirection
Type | Default | |
---|---|---|
TextDirection | Auto |
TextDirection in which the text is rendered.
Thread safety | ReadSafe |
---|---|
Category | Text |
Loaded/Saved | true |
History 1
- 581 Add TextDirection
TextFits
Type | Default | |
---|---|---|
bool | false |
A boolean representation of whether the button's text fits within the size of it.
Thread safety | ReadSafe |
---|---|
Category | Text |
Loaded/Saved | false |
TextScaled
Type | Default | |
---|---|---|
bool | false |
This property determines whether text is scaled so that it fills the button's entire space. When enabled, TextSize is ignored and TextWrapped is automatically enabled. This property is useful for rendering text elements within BillboardGuis. When this property is used for on-screen UI, it may be helpful to use a UITextSizeConstraint to restrict the range of possible text sizes.
Automatic Sizing
It's recommended that you avoid usage of TextScaled and adjust UI to take advantage of the AutomaticSize property instead. Here are the core differences between the two properties:
TextScaled scales the content (text) to accommodate the UI. Without careful consideration, some text may become unreadable if scaled too small.
AutomaticSize resizes the UI to accommodate content while maintaining a consistent font size. For more information, see here.
Additionally, it's recommended that you avoid applying both AutomaticSize and TextScaled and to the same TextButton. AutomaticSize determines the maximum amount of available space that a GuiObject can use (in this case, text), while TextScaled uses the available space determined by AutomaticSize to scale the font size up to the maximum font size (100) if there are no size constraints.
Thread safety | ReadSafe |
---|---|
Category | Text |
Loaded/Saved | true |
History 4
- 553 Change Default of TextScaled from to false
- 486 Change ThreadSafety of TextScaled from ReadOnly to ReadSafe
- 462 Change ThreadSafety of TextScaled from to ReadOnly
- 50 Add TextScaled
TextSize
Type | Default | |
---|---|---|
float | 8 |
This property determines the height of one line of rendered text. The unit is in offsets, not points (which is used in most document editing programs). The Font.Legacy font does not hold this property.
Thread safety | ReadSafe |
---|---|
Category | Text |
Loaded/Saved | true |
TextStrokeColor3
Type | Default | |
---|---|---|
Color3 | 0, 0, 0 |
This property sets the color of the stroke, or outline, of rendered text. Along with TextStrokeTransparency, it determines the final visual appearance of the text stroke.
As a powerful alternative which supports color gradients, see UIStroke.
Thread safety | ReadSafe |
---|---|
Category | Text |
Loaded/Saved | true |
History 4
- 553 Change Default of TextStrokeColor3 from to Color3(0, 0, 0)
- 486 Change ThreadSafety of TextStrokeColor3 from ReadOnly to ReadSafe
- 462 Change ThreadSafety of TextStrokeColor3 from to ReadOnly
- 48 Add TextStrokeColor3
TextStrokeTransparency
Type | Default | |
---|---|---|
float | 1 |
This property sets the transparency of the stroke, or outline, of rendered text. Along with TextStrokeColor3, it determines the final visual appearance of the text stroke.
Note that text stroke is multiple renderings of the same transparency, so
this property is essentially multiplicative on itself four times over.
Therefore, it's recommended to set
TextStrokeTransparency to a
value in the range of 0.75
to 1
for more a more subtle effect.
As a powerful alternative which supports color gradients, see UIStroke.
Thread safety | ReadSafe |
---|---|
Category | Text |
Loaded/Saved | true |
History 4
- 553 Change Default of TextStrokeTransparency from to 1
- 486 Change ThreadSafety of TextStrokeTransparency from ReadOnly to ReadSafe
- 462 Change ThreadSafety of TextStrokeTransparency from to ReadOnly
- 48 Add TextStrokeTransparency
TextTransparency
Type | Default | |
---|---|---|
float | 0 |
This property determines the transparency of all the text rendered by the TextButton.
Thread safety | ReadSafe |
---|---|
Category | Text |
Loaded/Saved | true |
History 4
- 553 Change Default of TextTransparency from to 0
- 486 Change ThreadSafety of TextTransparency from ReadOnly to ReadSafe
- 462 Change ThreadSafety of TextTransparency from to ReadOnly
- 47 Add TextTransparency
TextTruncate
Type | Default | |
---|---|---|
TextTruncate | None |
Controls the truncation of the text displayed in the TextButton.
Thread safety | ReadSafe |
---|---|
Category | Text |
Loaded/Saved | true |
History 4
- 553 Change Default of TextTruncate from to None
- 486 Change ThreadSafety of TextTruncate from ReadOnly to ReadSafe
- 462 Change ThreadSafety of TextTruncate from to ReadOnly
- 326 Add TextTruncate
TextWrap
Type | Default | |
---|---|---|
bool | false |
This property determines whether or not text should wrap at the edges of the TextButton element's space.
Thread safety | ReadSafe |
---|---|
Category | Text |
Loaded/Saved | true/false |
History 6
- 553 Change Default of TextWrap from to false
- 553 Change PreferredDescriptor of TextWrap from to TextWrapped
- 486 Change ThreadSafety of TextWrap from ReadOnly to ReadSafe
- 462 Change ThreadSafety of TextWrap from to ReadOnly
- 51 Change Tags of TextWrap from [NotReplicated] to [NotReplicated, Deprecated]
- 47 Add TextWrap
TextWrapped
Type | Default | |
---|---|---|
bool | false |
When enabled, this property will render text on multiple lines within a TextButton element's space so that TextBounds will never exceed the GuiBase2d.AbsoluteSize of the element. This is achieved by breaking long lines of text into multiple lines.
Line breaks will prefer whitespace; should a long unbroken word exceed the width of the element, that word will be broken into multiple lines.
If further line breaks would cause the vertical height of the text (the Y component of TextBounds) to exceed the vertical height of the element (the Y component of GuiBase2d.AbsoluteSize), then that line will not be rendered at all.
Thread safety | ReadSafe |
---|---|
Category | Text |
Loaded/Saved | true |
History 4
- 553 Change Default of TextWrapped from to false
- 486 Change ThreadSafety of TextWrapped from ReadOnly to ReadSafe
- 462 Change ThreadSafety of TextWrapped from to ReadOnly
- 51 Add TextWrapped
TextXAlignment
Type | Default | |
---|---|---|
TextXAlignment | Center |
This property determines the horizontal alignment of text rendered within the object's space. It is used in conjunction with TextYAlignment to fully determine text alignment on both axes.
Note that this property won't affect the read-only properties TextBounds and TextFits.
Thread safety | ReadSafe |
---|---|
Category | Text |
Loaded/Saved | true |
History 4
- 553 Change Default of TextXAlignment from to Center
- 486 Change ThreadSafety of TextXAlignment from ReadOnly to ReadSafe
- 462 Change ThreadSafety of TextXAlignment from to ReadOnly
- 47 Add TextXAlignment
TextYAlignment
Type | Default | |
---|---|---|
TextYAlignment | Center |
This property determines the vertical alignment of text rendered within the object's space. It is used in conjunction with TextXAlignment to fully determine text alignment on both axes.
Note that this property won't affect the read-only properties TextBounds and TextFits.
Thread safety | ReadSafe |
---|---|
Category | Text |
Loaded/Saved | true |
History 4
- 553 Change Default of TextYAlignment from to Center
- 486 Change ThreadSafety of TextYAlignment from ReadOnly to ReadSafe
- 462 Change ThreadSafety of TextYAlignment from to ReadOnly
- 47 Add TextYAlignment