Coordinates, Units & Anchors
Master GRUB 2 hybrid coordinates (px, %, 50%-260) and Grub Designer's 3x3 anchor matrix for multi-resolution themes.
On this page
Three unit modes in GRUB 2
Every positioned component in theme.txt supports three coordinate forms for left, top, width, and height:
| Mode | Syntax example | Meaning | Best for |
|---|---|---|---|
| Absolute pixels | left = 120 |
Exact pixel offset from the parent's top-left corner | Fixed-size badges, icons, and strict single-resolution layouts |
| Percentage | width = 40% |
Fraction of the parent's width or height | Fluid panels that scale across 720p, 1080p, and 4K |
Hybrid (%±px) |
left = 50%-260 |
Percentage anchor plus or minus a pixel offset | Centering fixed-width panels (50% - width/2) and pinning footers (100%-64) |
theme.txt
# Centered 520x360 boot menu on any screen resolution
+ boot_menu {
left = 50%-260
top = 50%-180
width = 520
height = 360
}
# Pinned 48px above the bottom edge, centered horizontally
+ label {
left = 50%-220
top = 100%-48
width = 440
align = "center"
text = "@KEYMAP_SHORT@"
}
How Grub Designer's 3×3 anchor matrix helps
Calculating 50%-260 or 100%-84 manually every time you resize a panel is tedious and error-prone. Grub Designer translates a 3×3 anchor matrix (nw, n, ne, w, c, e, sw, s, se) directly into clean GRUB hybrid coordinates:
- Selecting the Center (
c) anchor automatically writes50%-halfWidthand50%-halfHeight. - Selecting Bottom-Right (
se) automatically writes100%-offsetXand100%-offsetY. - Dragging a widget with Smart Guides snaps cleanly to viewport centerlines and sibling edges while preserving your chosen unit mode.
Parent-relative coordinate space
When a component is placed inside a canvas, its left, top, width, and height are computed relative to the canvas bounds, not the full screen.
By contrast, direct children of hbox and vbox do not use left or top at all — read the next guide to understand why.