Skip to documentation content

Containers: hbox, vbox & canvas

Why hbox and vbox auto-compute their dimensions from their children, why manual resizing behaves differently, and when to use canvas.

Why you cannot freely resize an hbox or vbox (or drag children inside them)

One of the most common surprises when building GRUB 2 themes in Grub Designer is placing components inside an hbox or vbox and noticing:

  1. The hbox / vbox container itself has no manual W / H inputs or resize handles.
  2. Direct child components inside an hbox / vbox cannot be dragged to arbitrary (left, top) positions.

This is not a limitation of the editor — it is the exact layout algorithm implemented in GNU GRUB 2's C source (grub-core/gfxmenu/gui_box.c). Try the interactive simulator below to see how hbox, vbox, and canvas behave when children change size:

36px
136px
W / H: auto (276×36 px via gui_box.c)left / top ignored by parent
img
label
progress

hbox stacks children left-to-right and automatically computes its own width (sum of children) and height (tallest child). Manual W/H handles on the container and left/top offsets on children do not exist in GRUB 2.

Interactive comparison of hbox, vbox, and canvas child sizing in GRUB 2

How hbox works (Horizontal Box)

hbox arranges its visible children left-to-right in a single horizontal row:

  • Container width: Automatic sum of every child's width.
  • Container height: Automatic height of the tallest child.
  • Child left and top: Ignored by GRUB 2 and omitted from theme.txt. Children are positioned strictly in layer order.
  • Changing the size of an hbox: Select a child directly (using Ctrl + Click on the canvas or selecting it in the Layers tree) and resize the child's width or height (for resizable widgets like image or progress_bar), or adjust its font/text (for auto-sized widgets like label). The parent hbox immediately expands or shrinks to fit.

How vbox works (Vertical Box)

vbox arranges its visible children top-to-bottom in a single vertical column:

  • Container width: Automatic width of the widest child.
  • Container height: Automatic sum of every child's height.
  • Child left and top: Ignored by GRUB 2 and omitted from theme.txt.

How canvas works (Free Positioning Container)

If you want a grouped container with explicit width and height where every child can be dragged and resized freely to exact (left, top) coordinates, use canvas instead of hbox/vbox:

Behavior hbox vbox canvas
Explicit width & height No (auto-computed) No (auto-computed) Yes (8-handle resize)
Child left & top offsets Ignored Ignored Yes (relative to canvas)
Overlapping children No (sequential row) No (sequential column) Yes (layer z-order)
Ideal use case Footer keycap rows, icon + countdown pairs Stacked status lines Modal cards, complex HUD groups

Working smoothly with containers in Grub Designer

  • Single Click on any child inside a container selects the root container so you can reposition the whole group cleanly on the viewport.
  • Ctrl + Click (or clicking the child in the Layers (L) panel) selects the individual child directly so you can edit its properties, reorder it, or resize it if its widget type supports manual bounds.
  • Need spacing between items inside an hbox or vbox? Add padding inside your child artwork or insert a lightweight transparent image spacer with the exact pixel width or height you want.