Class
TextLabel
A 2D user interface element that displays non-interactive text.
A TextLabel renders a rectangle, like a Frame, with styled
text. The rectangle can be used to define text boundaries, text scaling
(TextScaled), wrapping
(TextWrapped), and alignment
(TextXAlignment and/or
TextYAlignment).
This class contains properties that control the display of the text, such as
Font and TextColor3. To
display only text and hide the background rectangle, set
BackgroundTransparency to 1.
A UITextSizeConstraint object can be used to constrain the size of
text with TextScaled enabled. It is recommended
that the size of text is no lower than 9, otherwise it may not be visible to
many users.
Properties 26#
ContentTextstring | A copy of TextLabel.Text that contains exactly what is being
rendered by the TextLabel.ReadSafeReadOnlyNotReplicated |
FontEnum.Font | Determines the font used to render text.ReadSafeHiddenNotReplicated |
FontFaceDatatype.Font | Determines the font used to render text.ReadSafe |
FontSizeFontSize | Determines the font size to be used.ReadSafeDeprecatedNotReplicated |
LineHeightfloat | Scales the spacing between lines of text in the TextLabel.ReadSafe |
LocalizedTextstring | Read-only string containing the automatically-localized text that the
TextLabel renders.ReadSafeHiddenReadOnlyNotReplicated |
MaxVisibleGraphemesint | The maximum number of graphemes the TextLabel can show.ReadSafe |
OpenTypeFeaturesstring | Applies OpenType typographic features to the text rendered by the
TextLabel.ReadSafe |
OpenTypeFeaturesErrorstring | Read-only property that describes why the
TextLabel.OpenTypeFeatures string could not be applied.ReadSafeReadOnlyNotReplicated |
RichTextboolean | Determines whether the TextLabel renders its text using rich text
formatting.ReadSafe |
Textstring | Determines the string rendered by the TextLabel.ReadSafe |
TextBoundsVector2 | Read-only property which reflects the absolute size of rendered text inReadSafeReadOnlyNotReplicated |
TextColorBrickColor | Determines the color of text.ReadSafeDeprecatedHiddenNotReplicated |
TextColor3Color3 | Determines the color of rendered text.ReadSafe |
TextDirectionTextDirection | Direction in which the text is rendered.ReadSafe |
TextFitsboolean | A boolean representation of whether the label's text fits within the size of it.ReadSafeReadOnlyNotReplicated |
TextScaledboolean | Changes whether text is resized to fit within the TextLabel.ReadSafe |
TextSizefloat | Determines the line height of text in offsets.ReadSafe |
TextStrokeColor3Color3 | Determines the color of the text stroke (outline).ReadSafe |
TextStrokeTransparencyfloat | Determines the transparency of the text stroke (outline).ReadSafe |
TextTransparencyfloat | Determines the transparency of rendered text.ReadSafe |
TextTruncateTextTruncate | Controls the truncation of the text displayed in the TextLabel.ReadSafe |
TextWrapboolean | Determines whether or not text should wrap at the edges of the
TextLabel element's space.ReadSafeDeprecatedNotReplicated |
TextWrappedboolean | Determines if text wraps to multiple lines within the TextLabelReadSafe |
TextXAlignmentTextXAlignment | Determines the horizontal alignment of rendered text.ReadSafe |
TextYAlignmentTextYAlignment | Determines the vertical alignment of rendered text.ReadSafe |
ContentText: string#
ReadOnlyNotReplicatedReadSafe
This property provides a copy of Text that contains
exactly what is being rendered by the TextLabel. 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! |
Font: Enum.Font#
HiddenNotReplicatedReadSafe
This property selects one of several pre-defined fonts with which the
TextLabel will render its text. Some fonts have bold, italic
and/or light variants.
With the exception of the Font.Legacy font, each font will render
text with the line height equal to the TextSize
property.
The Font.Code font is the only monospace font. It has the unique
property that each character has the exact same width and height ratio of
1:2, where the width of each character is approximately half the
TextSize property.
This property is kept in sync with the FontFace
property.
FontFace: Datatype.Font#
ReadSafe
FontSize: FontSize#
NotReplicatedDeprecatedReadSafeDeprecated
Deprecated. This property is deprecated in favor of TextSize which
is an integer and not an enum and thus offers far more options for sizes.
This property determines the font size to be used.
LineHeight: float#
ReadSafe
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 TextLabel.
Valid values range from 1.0 to 3.0, defaulting to 1.0.
LocalizedText: string#
HiddenReadOnlyNotReplicatedReadSafe
This read-only property holds the automatically-localized text that the
TextLabel renders. When automatic localization is enabled through
AutoLocalize and the label's
Text matches an entry in an applicable localization
table for the player's locale, this property contains the translated
string that is actually displayed; when no translation applies, it falls
back to the label's own text. It defaults to an empty string and can't be
set from a script.
MaxVisibleGraphemes: int#
ReadSafe
This property controls the maximum number of graphemes (or units of text)
that are shown on the TextLabel. 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.
OpenTypeFeatures: string#
ReadSafe
This property is a comma-separated list of OpenType feature tags that are
applied when the TextLabel shapes and renders its text, such as
zero for slashed zeros or ss03 for a stylistic set. It defaults to an
empty string, which applies no additional features.
Each entry uses the standard OpenType feature-string syntax (for example,
zero or ss03). Only a supported subset of features is applied; a
feature that isn't supported, a malformed string, or the bracketed
partial-enabling syntax (for example, zero[1:3]) is rejected, and the
reason is reported through
OpenTypeFeaturesError.
This property supports styling.
OpenTypeFeaturesError: string#
ReadOnlyNotReplicatedReadSafe
This read-only property reports the error, if any, encountered while
parsing and applying the
OpenTypeFeatures string. It defaults to
an empty string, which indicates that the requested features were applied
successfully.
When a feature can't be applied, this property is set to one of the following messages:
Failed to parse features.when a feature string is malformed.Unsupported feature:when a feature isn't part of the supported set.Partial feature enabling not supported.when the string uses the bracketed range syntax.
RichText: boolean#
ReadSafe
Text: string#
ReadSafe
This property determines the text content rendered by the
TextLabel. 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.
TextBounds: Vector2#
ReadOnlyNotReplicatedReadSafe
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.
TextColor: BrickColor#
HiddenNotReplicatedDeprecatedReadSafeDeprecated
Deprecated. This item has been superseded by TextLabel.TextColor3 which should
be used in all new work.
This property determines the color of text.
TextColor3: Color3#
ReadSafe
This property determines the color of all the text rendered by the
TextLabel element.
TextDirection: TextDirection#
ReadSafe
This property sets the base direction in which the TextLabel
orders and renders its text, using a value of the TextDirection
enum. It defaults to TextDirection.Auto, which infers the direction
from the content of Text so that left-to-right and
right-to-left scripts are ordered correctly. Set it to
TextDirection.LeftToRight or TextDirection.RightToLeft to
force a specific direction regardless of the text content.
This property supports styling.
TextFits: boolean#
ReadOnlyNotReplicatedReadSafe
This read-only property is true when the text rendered by the
TextLabel fits entirely within the element's
GuiBase2d.AbsoluteSize, and false when the text is too large and
is therefore clipped or truncated. It's computed from
TextBounds relative to the available space,
so it reflects the combined effect of
TextWrapped,
TextTruncate, and
TextScaled.
TextScaled: boolean#
ReadSafe
This property determines whether text is scaled so that it fills the
label'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:
TextScaledscales the content (text) to accommodate the UI. Without careful consideration, some text may become unreadable if scaled too small.AutomaticSizeresizes 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 TextLabel.
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.
TextSize: float#
ReadSafe
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.
TextStrokeColor3: Color3#
ReadSafe
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.
TextStrokeTransparency: float#
ReadSafe
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.
TextTransparency: float#
ReadSafe
This property determines the transparency of all the text rendered by the
TextLabel.
TextTruncate: TextTruncate#
ReadSafe
This property controls how the TextLabel truncates text that is
too large to fit within the element, using a value of the
TextTruncate enum. It defaults to TextTruncate.None, which
leaves text untruncated. TextTruncate.AtEnd truncates at word
boundary and replaces the overflowing graphemes with an ellipsis (...),
respecting word boundaries where possible, while
TextTruncate.SplitWord truncates inside a word when the line ends
in the middle of one.
This property supports styling.
TextWrap: boolean#
NotReplicatedDeprecatedReadSafeDeprecated
Deprecated. This property is simply an alias for TextWrapped. Use
the past-tense version instead.
This property determines whether or not text should wrap at the edges of
the TextLabel element's space.
TextWrapped: boolean#
ReadSafe
When enabled, this property will render text on multiple lines within a
TextLabel 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.
TextXAlignment: TextXAlignment#
ReadSafe
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.
TextYAlignment: TextYAlignment#
ReadSafe
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.
Inherited members#
Inherited from GuiObject 51
Properties (30)
Active, AnchorPoint, AutomaticSize, BackgroundColor, BackgroundColor3, BackgroundTransparency, BorderColor, BorderColor3, BorderMode, BorderSizePixel, ClipsDescendants, Draggable, GuiState, InputSink, Interactable, LayoutOrder, NextSelectionDown, NextSelectionLeft, NextSelectionRight, NextSelectionUp, Position, Rotation, Selectable, SelectionImageObject, SelectionOrder, Size, SizeConstraint, Transparency, Visible, ZIndex
Methods (3)
Inherited from GuiBase2d 12
Properties (11)
AbsolutePosition, AbsoluteRotation, AbsoluteSize, AutoLocalize, Localize, RootLocalizationTable, SelectionBehaviorDown, SelectionBehaviorLeft, SelectionBehaviorRight, SelectionBehaviorUp, SelectionGroup
Events (1)
Inherited from Instance 58
Properties (10)
Archivable, archivable, Capabilities, IsInSandbox, Name, Parent, PredictionMode, RobloxLocked, Sandboxed, UniqueId
Methods (39)
AddTag, children, ClearAllChildren, Clone, clone, Destroy, destroy, FindFirstAncestor, FindFirstAncestorOfClass, FindFirstAncestorWhichIsA, FindFirstChild, findFirstChild, FindFirstChildOfClass, FindFirstChildWhichIsA, FindFirstDescendant, GetActor, GetAttribute, GetAttributeChangedSignal, GetAttributes, GetChildren, getChildren, GetDebugId, GetDescendants, GetFullName, GetStyled, GetStyledPropertyChangedSignal, GetTags, HasTag, IsAncestorOf, IsDescendantOf, isDescendantOf, IsPropertyModified, QueryDescendants, Remove, remove, RemoveTag, ResetPropertyToDefault, SetAttribute, WaitForChild