Components
Documentation content

Spacer

Use spacer for empty space between siblings. grow fills unused space on the main axis, which can push toolbar actions to the trailing edge. Set width or height for a fixed gap. Use separator for a visible dividing line.

spacer
A spacer pushing a toolbar action to the far edge, rendered by the engine (light theme)
a grow spacer pushing the action button to the trailing edge

Markup

<panel width="340" padding="12">
  <row gap="12" cross="center">
    <text>Docs</text>
    <text foreground="text_muted">Source</text>
    <spacer grow="1"></spacer>
    <button size="sm" variant="secondary" on-press="open_changelog">Changelog</button>
  </row>
</panel>

Programmatic construction (Zig)

In a Zig view, the canvas.Ui builder constructs the same tree programmatically. ui.spacer(1) is the builder shorthand for a grow-1 spacer.

ui.panel(.{ .width = 340, .padding = 12 }, .{
    ui.row(.{ .gap = 12, .cross = .center }, .{
        ui.text(.{}, "Docs"),
        ui.text(.{ .style_tokens = .{ .foreground = .text_muted } }, "Source"),
        ui.spacer(1),
        ui.button(.{ .size = .sm, .variant = .secondary, .on_press = .open_changelog }, "Changelog"),
    }),
})

Attributes

AttributeDescription
widthDefinite width (plain number): the element is exactly this wide; content neither shrinks nor overflows it. On resizable it is the initial width.
heightDefinite height (plain number): the element is exactly this tall; content neither shrinks nor overflows it.
growFlex grow factor; give spacer one.