Expand 2+ line label horizontally

Godot Version

v4.5.stable.official [876b29033]

Question

Is there a way to have a 2+ line tall text box that expands horizontally when the text doesn’t fit in it? I only manage to expand Label and RichTextLabel horizontally on exactly 1 line. If I change the Autowrap mode, it can expand vertically, but loses the ability to expand horizontally.

Desired features:

  • Always 2 lines tall (or some other static number, not 1)
  • Expands horizontally when needed (never vertically)

Don’t put a third line of text into it.

There’s also max_lines_visible property.

I do not follow.

max_lines_visible hides the extra lines. I want all text input to be shown, expanding the label horizontally if needed.

I think it’s not possible by setting specific parameters in the inspector. As far as I know, I have to add custom script for this.

As I said; if you don’t want the third line, don’t put more than two lines of text into the label. Process your string before putting it into label.

To be honest, while your initial answer was correct, it was so vague that it was hard to understand what you meant by it.

I will process the text to find a halfway point and inject a single line break (unless it’s so short it doesn’t need one).