Start UI scene with a Control node or a Container

Godot Version

4.6(any version actually)

Question

When watching tutorials or reading blog posts about building UIs in Godot, I often notice that some developers start with a Control node as the root node, while others start with a container (PanelContainer, ScrollContainer, and so on) as the scene’s root node.

Although the final UI doesn’t change in terms of its goal, I’m confused about whether it’s better to start a scene with a Control node as the root of the scene or if I can use a container directly when creating an interface. Keep in mind that I’m referring to building user interfaces for desktop applications, not games per se.

Any thoughts on which of the two nodes to use to build an UI? In this situation, does it matter which node you start with?

Thanks in advance!

Depends on if you want to use containers or anchors. If you use the scene instantiated as a child of other containers then it’s root node should be a container type too.

1 Like

For a desktop UI, I’d usually use a Control root and put containers inside wherever layout needs them. A container root is fine if the scene is meant to be dropped into another container, but Control is the safer default for a top-level screen.

Hi! Sorry for the late reply.

Depends on if you want to use containers or anchors.

Since containers are children of the Control node, wouldn’t they already inherit all the anchor behavior that Control already has?

They do, but containers control the position and size of their children, so anchors do nothing for such children of containers.

There are many times where you might want to consider using a control node as root that is neither the basic simple control nor a container. Like maybe you just want to make a wacky looking spinbox or some custom ui configuration of controls where you want custom anchoring instead of the containers arrangements.