## GtkBox GtkBox — A container for packing widgets in a single row or column |

## Functions

GtkWidget * | gtk_box_new ()
gboolean | gtk_box_get_homogeneous ()
void | gtk_box_set_homogeneous ()
gint | gtk_box_get_spacing ()
void | gtk_box_set_spacing ()
GtkBaselinePosition | gtk_box_get_baseline_position ()
void | gtk_box_set_baseline_position ()
void | gtk_box_append ()
void | gtk_box_prepend ()
void | gtk_box_remove ()
void | gtk_box_insert_child_after ()
void | gtk_box_reorder_child_after ()

## Properties

GtkBaselinePosition | baseline-position | Read / Write
gboolean | homogeneous | Read / Write
gint | spacing | Read / Write

## Types and Values

struct | GtkBox
struct | GtkBoxClass

## Object Hierarchy

        GObject
        ╰── GInitiallyUnowned
            ╰── GtkWidget
                ╰── GtkBox
                    ├── GtkShortcutsSection
                    ╰── GtkShortcutsGroup

## Implemented Interfaces

GtkBox implements AtkImplementorIface, GtkBuildable, GtkConstraintTarget and GtkOrientable.

## Includes

    #include <gtk/gtk.h>

## Description

The GtkBox widget arranges child widgets into a single row or column, depending upon the value of its “orientation” property. Within the other dimension, all children are allocated the same size. Of course, the “halign” and “valign” properties can be used on the children to influence their allocation.

Use repeated calls to `gtk_box_append()` to pack widgets into a GtkBox from start to end. Use `gtk_box_remove()` to remove widgets from the GtkBox. `gtk_box_insert_child_after()` can be used to add a child at a particular position.

Use `gtk_box_set_homogeneous()` to specify whether or not all children of the GtkBox are forced to get the same amount of space.

Use `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 `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.

## Functions

### gtk_box_new ()

    GtkWidget *
    gtk_box_new (GtkOrientation orientation,
                 gint spacing);

Creates a new GtkBox.

#### Parameters

orientation | the box’s orientation. |
spacing | the number of pixels to place by default between children. |

#### Returns

a new GtkBox.

### gtk_box_get_homogeneous ()

    gboolean
    gtk_box_get_homogeneous (GtkBox *box);

Returns whether the box is homogeneous (all children are the same size). See `gtk_box_set_homogeneous()`.

#### Parameters

box | a GtkBox |

#### Returns

`TRUE` if the box is homogeneous.

### gtk_box_set_homogeneous ()

    void
    gtk_box_set_homogeneous (GtkBox *box,
                             gboolean homogeneous);

Sets the “homogeneous” property of `box` , controlling whether or not all children of `box` are given equal space in the box.

#### Parameters

box | a GtkBox |
homogeneous | a boolean value, `TRUE` to create equal allotments, `FALSE` for variable allotments |

### gtk_box_get_spacing ()

    gint
    gtk_box_get_spacing (GtkBox *box);

Gets the value set by `gtk_box_set_spacing()`.

#### Parameters

box | a GtkBox |

#### Returns

spacing between children

### gtk_box_set_spacing ()

    void
    gtk_box_set_spacing (GtkBox *box,
                         gint spacing);

Sets the “spacing” property of `box` , which is the number of pixels to place between children of `box` .

#### Parameters

box | a GtkBox |
spacing | the number of pixels to put between children |

### gtk_box_get_baseline_position ()

    GtkBaselinePosition
    gtk_box_get_baseline_position (GtkBox *box);

Gets the value set by `gtk_box_set_baseline_position()`.

#### Parameters

box | a GtkBox |

#### Returns

the baseline position

### gtk_box_set_baseline_position ()

    void
    gtk_box_set_baseline_position (GtkBox *box,
                                   GtkBaselinePosition position);

Sets the baseline position of a box. This affects only horizontal boxes with at least one baseline aligned child. If there is more vertical space available than requested, and the baseline is not allocated by the parent then `position` is used to allocate the baseline wrt the extra space available.

#### Parameters

box | a GtkBox |
position | a GtkBaselinePosition |

### gtk_box_append ()

    void
    gtk_box_append (GtkBox *box,
                    GtkWidget *child);

Adds `child` as the last child to `box` .

#### Parameters

box | a GtkBox |
child | the GtkWidget to append |

### gtk_box_prepend ()

    void
    gtk_box_prepend (GtkBox *box,
                     GtkWidget *child);

Adds `child` as the first child to `box` .

#### Parameters

box | a GtkBox |
child | the GtkWidget to prepend |

### gtk_box_remove ()

    void
    gtk_box_remove (GtkBox *box,
                    GtkWidget *child);

Removes a child widget from `box` , after it has been added with `gtk_box_append()`, `gtk_box_prepend()`, or `gtk_box_insert_child_after()`.

#### Parameters

box | a GtkBox |
child | the child to remove |

### gtk_box_insert_child_after ()

    void
    gtk_box_insert_child_after (GtkBox *box,
                                GtkWidget *child,
                                GtkWidget *sibling);

Inserts `child` in the position after `sibling` in the list of `box` children. If `sibling` is `NULL`, insert `child` at the first position.

#### Parameters

box | a GtkBox |
child | the GtkWidget to insert |
sibling | the sibling to move `child` after, or `NULL`. | [nullable]

### gtk_box_reorder_child_after ()

    void
    gtk_box_reorder_child_after (GtkBox *box,
                                 GtkWidget *child,
                                 GtkWidget *sibling);

Moves `child` to the position after `sibling` in the list of `box` children. If `sibling` is `NULL`, move `child` to the first position.

#### Parameters

box | a GtkBox |
child | the GtkWidget to move, must be a child of `box` |
sibling | the sibling to move `child` after, or `NULL`. | [nullable]

## Types and Values

### struct GtkBox

    struct GtkBox;

### struct GtkBoxClass

    struct GtkBoxClass {
      GtkWidgetClass parent_class;
    };

#### Members

## Property Details

### The `“baseline-position”` property

      “baseline-position”        GtkBaselinePosition

The position of the baseline aligned widgets if extra space is available.

Owner: GtkBox

Flags: Read / Write

Default value: GTK_BASELINE_POSITION_CENTER

### The `“homogeneous”` property

      “homogeneous”              gboolean

Whether the children should all be the same size.

Owner: GtkBox

Flags: Read / Write

Default value: FALSE

### The `“spacing”` property

      “spacing”                  gint

The amount of space between children.

Owner: GtkBox

Flags: Read / Write

Allowed values: >= 0

Default value: 0

## See Also

GtkGrid