How to put color behind something (UI)

Godot Version

v4.2.2.stable.official [15073afe3]

Question

How can I place a colorrect behind the h-box? I can’t for the life of me figure it out.
Heres the screenshot:

Just make it as a child of HBoxContainer and set it to Show Behind Parent

That places it in the top left and when i change the anchor it moves the Hbox as well!

just make the color rect as a child of HBoxContainer
something like this

image

nvm i just knew the problem
here’s the right way:

One sec, lemme try

Cool! Thanks :slight_smile:

1 Like

if you want some margin here’s how too:

The background of the panel is in the theme yeah?

yes, theme overrides

Dope, Thanks for all the help! UI is a huge challenge for me

Last thing, How can I update the label width when I change the text in code? Do you know

in default, it should auto adjust its width to the whole texts size, unless you word wrap it
if you word wrap the label, try set a custom minimum size of X to a certain number so it doesnt just fall down

I have returned! Here’s what i mean. When the label text gets changed the box doesnt re-size appropriately. Sorry to be a bother btw

mine works fine here:
label

did you manually set the panel container size?

No? It just did that for me. I’ll go click random buttons till it works

i think i know why
you will need to empty the label text, then in the panel container, click the reset button for size, then it should resize back to the smallest with no text

It actually doesn’t let me change the text size, I think its stuck with the container. Maybe i hit a wrong button on the way, I’m going to re-build it

not text size, i mean panel container’s size
so after you set the text to empty
go to panel container inspector, set the size to most minimum

Well, That fixed that but now its not centering. This is alot harder than expected