Reference API Roblox

Engine API

Website

Related

Reference API Roblox

TextButton

A 2D user interface element that displays interactive text.

Member index 29

HistoryMember
726ContentText: string
726FontFace: Font
726FontSize: FontSize
726LineHeight: float
726MaxVisibleGraphemes: int
629OpenTypeFeatures: string
629OpenTypeFeaturesError: string
726RichText: bool
726Text: string
726TextBounds: Vector2
726TextColor3: Color3
726TextDirection: TextDirection
726TextFits: bool
726TextScaled: bool
726TextSize: float
726TextStrokeColor3: Color3
726TextStrokeTransparency: float
726TextTransparency: float
726TextTruncate: TextTruncate
726TextWrap: bool
726TextWrapped: bool
726TextXAlignment: TextXAlignment
726TextYAlignment: TextYAlignment
573SetTextFromInput(text: string): null
inherited from GuiButton
726AutoButtonColor: bool
726HoverHapticEffect: HapticEffect
726Modal: bool
726PressHapticEffect: HapticEffect
726Selected: bool
726Style: ButtonStyle
483Activated(inputObject: InputObject, clickCount: int)
462MouseButton1Click()
462MouseButton1Down(x: int, y: int)
462MouseButton1Up(x: int, y: int)
462MouseButton2Click()
462MouseButton2Down(x: int, y: int)
462MouseButton2Up(x: int, y: int)
687SecondaryActivated(inputObject: InputObject)
inherited from GuiObject
726Active: bool
726AnchorPoint: Vector2
726AutomaticSize: AutomaticSize
726BackgroundColor3: Color3
726BackgroundTransparency: float
726BorderColor3: Color3
726BorderMode: BorderMode
726BorderSizePixel: int
726ClipsDescendants: bool
726Draggable: bool
726GuiState: GuiState
726InputSink: InputSink
726Interactable: bool
726LayoutOrder: int
726NextSelectionDown: GuiObject
726NextSelectionLeft: GuiObject
726NextSelectionRight: GuiObject
726NextSelectionUp: GuiObject
726Position: UDim2
726Rotation: float
726Selectable: bool
726SelectionImageObject: GuiObject
726SelectionOrder: int
726Size: UDim2
726SizeConstraint: SizeConstraint
726Visible: bool
726ZIndex: int
462TweenPosition(endPosition: UDim2, easingDirection: EasingDirection = Out, easingStyle: EasingStyle = Quad, time: float = 1, override: bool = false, callback: Function = nil): bool
713TweenPositionInternal(endPosition: UDim2, easingDirection: EasingDirection = Out, easingStyle: EasingStyle = Quad, time: float = 1, override: bool = false, callback: Function = nil): bool
462TweenSize(endSize: UDim2, easingDirection: EasingDirection = Out, easingStyle: EasingStyle = Quad, time: float = 1, override: bool = false, callback: Function = nil): bool
462TweenSizeAndPosition(endSize: UDim2, endPosition: UDim2, easingDirection: EasingDirection = Out, easingStyle: EasingStyle = Quad, time: float = 1, override: bool = false, callback: Function = nil): bool
713TweenSizeAndPositionInternal(endSize: UDim2, endPosition: UDim2, easingDirection: EasingDirection = Out, easingStyle: EasingStyle = Quad, time: float = 1, override: bool = false, callback: Function = nil): bool
713TweenSizeInternal(endSize: UDim2, easingDirection: EasingDirection = Out, easingStyle: EasingStyle = Quad, time: float = 1, override: bool = false, callback: Function = nil): bool
462DragBegin(initialPosition: UDim2)
462DragStopped(x: int, y: int)
483InputBegan(input: InputObject)
483InputChanged(input: InputObject)
483InputEnded(input: InputObject)
462MouseEnter(x: int, y: int)
462MouseLeave(x: int, y: int)
462MouseMoved(x: int, y: int)
462MouseWheelBackward(x: int, y: int)
462MouseWheelForward(x: int, y: int)
462SelectionGained()
462SelectionLost()
462TouchLongPress(touchPositions: Array, state: UserInputState)
462TouchPan(touchPositions: Array, totalTranslation: Vector2, velocity: Vector2, state: UserInputState)
462TouchPinch(touchPositions: Array, scale: float, velocity: float, state: UserInputState)
462TouchRotate(touchPositions: Array, rotation: float, velocity: float, state: UserInputState)
462TouchSwipe(swipeDirection: SwipeDirection, numberOfTouches: int)
462TouchTap(touchPositions: Array)
inherited from GuiBase2d
726AbsolutePosition: Vector2
726AbsoluteRotation: float
726AbsoluteSize: Vector2
726AutoLocalize: bool
726RootLocalizationTable: LocalizationTable
726SelectionBehaviorDown: SelectionBehavior
726SelectionBehaviorLeft: SelectionBehavior
726SelectionBehaviorRight: SelectionBehavior
726SelectionBehaviorUp: SelectionBehavior
726SelectionGroup: bool
525SelectionChanged(amISelected: bool, previousSelection: GuiObject, newSelection: GuiObject)
inherited from Instance
726Archivable: bool
726Capabilities: SecurityCapabilities
726IsInSandbox: bool
726Name: string
726Parent: Instance
726PredictionMode: PredictionMode
726Sandboxed: bool
726UniqueId: UniqueId
576AddTag(tag: string): null
573ClearAllChildren(): null
462Clone(): Instance
573Destroy(): null
486FindFirstAncestor(name: string): Instance
486FindFirstAncestorOfClass(className: string): Instance
486FindFirstAncestorWhichIsA(className: string): Instance
486FindFirstChild(name: string, recursive: bool = false): Instance
486FindFirstChildOfClass(className: string): Instance
486FindFirstChildWhichIsA(className: string, recursive: bool = false): Instance
486FindFirstDescendant(name: string): Instance
563GetActor(): Actor
486GetAttribute(attribute: string): Variant
462GetAttributeChangedSignal(attribute: string): RBXScriptSignal
631GetAttributes(): Dictionary
648GetChildren(): Instances
462GetDebugId(scopeLength: int = 4): string
707GetDescendants(): Instances
486GetFullName(): string
706GetStyled(name: string, selector: string?): Variant
657GetStyledPropertyChangedSignal(property: string): RBXScriptSignal
576GetTags(): Array
576HasTag(tag: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
664IsPropertyModified(property: string): bool
698QueryDescendants(selector: string): Instances
573Remove(): null
576RemoveTag(tag: string): null
664ResetPropertyToDefault(property: string): null
573SetAttribute(attribute: string, value: Variant): null
462WaitForChild(childName: string, timeOut: double): Instance
726children(): Instances
726clone(): Instance
726destroy(): null
726findFirstChild(name: string, recursive: bool = false): Instance
726getChildren(): Instances
726isDescendantOf(ancestor: Instance): bool
726remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
657StyledPropertiesChanged()
726childAdded(child: Instance)
inherited from Object
726ClassName: string
726className: string
647GetPropertyChangedSignal(property: string): RBXScriptSignal
647IsA(className: string): bool
726isA(className: string): bool
647Changed(property: string)

Removed member index 2

HistoryMember
466Content: 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 138

Members 29

ContentText

TypeDefault
string

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.

RichTextTextContentText
false<b>Hello,<br/> world!</b><b>Hello,<br/> world!</b>
true<b>Hello,<br/> world!</b>Hello,
world!
This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 3

Tags: [ReadOnly, NotReplicated]

FontFace

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

History 3

FontSize

TypeDefault
FontSize

This property determines the font size to be used.

This property is deprecated. It exists only for backward compatibility, and should not be used for new work.
This property is not replicated. Its interface does not cross the network boundary.

History 8

Tags: [NotReplicated, Deprecated]

LineHeight

TypeDefault
float

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.

History 5

MaxVisibleGraphemes

TypeDefault
int

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.

History 4

OpenTypeFeatures

TypeDefault
string

History 1

OpenTypeFeaturesError

TypeDefault
string
This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 1

Tags: [ReadOnly, NotReplicated]

RichText

TypeDefault
bool

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.

History 5

SetTextFromInput

Parameters (1)
textstring
Returns (1)
null

History 3

Text

TypeDefault
string

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.

History 5

  • 726 Change Default of Text from Button to
  • 553 Change Default of Text from to Button
  • 486 Change ThreadSafety of Text from ReadOnly to ReadSafe
  • 462 Change ThreadSafety of Text from to ReadOnly
  • 47 Add Text

TextBounds

TypeDefault
Vector2

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.

This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 5

Tags: [ReadOnly, NotReplicated]

TextColor3

TypeDefault
Color3

This property determines the color of all the text rendered by the TextButton element.

History 5

TextDirection

TypeDefault
TextDirection

TextDirection in which the text is rendered.

History 2

TextFits

TypeDefault
bool

A boolean representation of whether the button's text fits within the size of it.

This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 5

Tags: [ReadOnly, NotReplicated]

TextScaled

TypeDefault
bool

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.

History 5

TextSize

TypeDefault
float

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.

History 5

TextStrokeColor3

TypeDefault
Color3

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.

History 5

TextStrokeTransparency

TypeDefault
float

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.

History 5

TextTransparency

TypeDefault
float

This property determines the transparency of all the text rendered by the TextButton.

History 5

TextTruncate

TypeDefault
TextTruncate

Controls the truncation of the text displayed in the TextButton.

History 5

TextWrap

TypeDefault
bool

This property determines whether or not text should wrap at the edges of the TextButton element's space.

This property is deprecated. It exists only for backward compatibility, and should not be used for new work.
This property is not replicated. Its interface does not cross the network boundary.

History 8

Tags: [NotReplicated, Deprecated]

TextWrapped

TypeDefault
bool

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.

History 5

TextXAlignment

TypeDefault
TextXAlignment

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.

History 5

TextYAlignment

TypeDefault
TextYAlignment

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.

History 5

Removed members 2

Content

TypeDefault
string
This property is not replicated. Its interface does not cross the network boundary.
This property is read-only. Its value can be read, but it cannot be modified.

History 2

Tags: [ReadOnly, NotReplicated]

Settings