Arranges child widgets into a single row or column.
<picture> <source srcset="box-dark.png" media="(prefers-color-scheme: dark)"> <img alt="An example GtkBox" src="box.png"
> </picture>
Whether it is a row or column depends on the value of its [property@Gtk.Orientable:orientation] property. Within the other dimension, all
children are allocated the same size. The [property@Gtk.Widget:halign] and [property@Gtk.Widget:valign] properties can be used on the
children to influence their allocation.
Use repeated calls to [method@Gtk.Box.append] to pack widgets into a `GtkBox` from start to end. Use [method@Gtk.Box.remove] to remove
widgets from the `GtkBox`. [method@Gtk.Box.insert_child_after] can be used to add a child at a particular position.
Use [method@Gtk.Box.set_homogeneous] to specify whether or not all children of the `GtkBox` are forced to get the same amount of space.
Use [method@Gtk.Box.set_spacing] to determine how much space will be minimally placed between all children in the `GtkBox`. Note that
spacing is added *between* the children.
Use [method@Gtk.Box.reorder_child_after] to move a child to a different place in the box.
CSS nodes
`GtkBox` uses a single CSS node with name box.
Accessibility
Until GTK 4.10, `GtkBox` used the [enum@Gtk.AccessibleRole.group] role.
Starting from GTK 4.12, `GtkBox` uses the [enum@Gtk.AccessibleRole.generic] role.
- public BaselinePosition get_baseline_position ()
Gets the value set by [method@Gtk.
- public unowned Widget? get_center_widget ()
Retrieves the center widget of the box.
- public bool get_homogeneous ()
Returns whether the box is homogeneous.
- public int get_spacing ()
Gets the value set by [method@Gtk.
- public void pack_end (Widget child, bool expand = true, bool fill = true, uint padding = 0)
Adds child to this,
packed with reference to the end of this.
- public void pack_start (Widget child, bool expand = true, bool fill = true, uint padding = 0)
Adds child to this,
packed with reference to the start of this.
- public void query_child_packing (Widget child, out bool expand, out bool fill, out uint padding, out PackType pack_type)
Obtains information about how child is packed into
this.
- public void reorder_child (Widget child, int position)
Moves child to a new position in the list of
this children.
- public void set_baseline_position (BaselinePosition position)
Sets the baseline position of a box.
- public void set_center_widget (Widget? widget)
Sets a center widget; that is a child widget that will be centered
with respect to the full width of the box, even if the children at either side take up different amounts of space.
- public void set_child_packing (Widget child, bool expand, bool fill, uint padding, PackType pack_type)
Sets the way child is packed into
this.
- public void set_homogeneous (bool homogeneous)
Sets whether or not all children are given equal space in the box.
- public void set_spacing (int spacing)
Sets the number of pixels to place between children.