Automatic Sizing

The AutomaticSize property automatically resizes a parent GuiObject to the size of its descendants. By applying this property, you can dynamically add text and image content to a GuiObject, and its size actively adjusts to fit that content. You can use this property in a variety of use cases, including:

  • Localized text – Expanding a GuiObject to fit text that has been localized in many languages.
  • User input – Allowing users to input text within a TextBox, automatically adjusting its size based on the amount of text entered.
  • Dynamic Layouts – Utilizing UI layouts, such as UIListLayouts that automatically resize according to how many items are in their lists.
  • Scrolling Frames – Automatically resizing the canvas of a ScrollingFrame according to its content.
  • Rich Text – Automatically adjusting the size of text objects using rich text markup, including font type and size.

Enabling Automatic Sizing

You can enable the AutomaticSize property for any GuiObject. By default, it is set to None, but you can change its value to have specific control over which direction(s) the GuiObject resizes to fit its content.

To enable the AutomaticSize property:

  1. In the Explorer window, click any GuiObject, such as a Frame, TextBox, or ImageLabel.

  2. In the Properties window, navigate to the AutomaticSize property and set it to one of the following options:

    • X - Resizes content horizontally.

    • Y - Resizes content vertically.

    • XY - Resizes content both horizontally and vertically.

Customizing Automatic Sizing

In addition to enabling the AutomaticSize property, you can customize additional properties of your GuiObject that also impact its automatic sizing functionality.

AnchorPoint

Similar to the typical process of sizing a GuiObject, automatic sizing takes the AnchorPoint property into consideration when it's resizing content. For example, the following video displays three TextLabels that are automatically sizing their text content:

Size

When you enable the AutomaticSize property for a GuiObject, its Size property controls its minimum size. This means that the GuiObject cannot resize smaller than its starting size along any axis.

For example, the following white Frame has an X-axis size of 0, so it doesn't have a minimum width and can resize to the width of its child object.

In comparison, the following white Frame has an X size of 100, so it cannot resize smaller than 100 pixels.

TextWrapped

When you enable the TextWrapped property for a TextLabel, TextButton, or TextBox and set the AutomaticSize property to either Y or XY, the label resizes to accommodate any text that wraps across multiple lines. For example, the following TextLabel has TextWrapped enabled and a set AutomaticSize property of Y, so when a user types in more content, the TextLabel expands vertically.

TextScaled

Instead of enabling the TextScaled property for any TextLabels, TextButtons, and TextBoxes, use the AutomaticSize property for a GuiObject instead. This ensures that the text within your text objects maintains a consistent text size and never scales to a font size that is illegible. For more information, see the API Reference for TextLabel.TextScaled, TextButton.TextScaled, and TextBox.TextScaled.