PcoWSkbVqDnWTu_dm2ix
Collapse Sidebar

TextBounds

TextBox

Vector2

The read-only property TextBounds reflects the absolute pixel size of rendered text. In other words, if you were to try to fit text into a rectangle, this property would reflect the minimum dimensions of the rectangle you would need in order to fit the text.

Using TextService/GetTextSize, you can predict what TextBounds will be on a TextLabel given a string, TextBox/Font, TextBox/TextSize and frame size.


Code Samples


Dynamic TextBox Size

This code sample dynamically resizes a TextLabel, TextButton or TextBox to match the size of its TextBounds. Try changing the minimum width/height and pasting into a LocalScript in a TextBox.