WrapBox


Object Hierarchy:

Object hierarchy for WrapBox

Description:

[ CCode ( type_id = "adw_wrap_box_get_type ()" ) ]
[ Version ( since = "1.7" ) ]
public class WrapBox : Widget, Accessible, Buildable, ConstraintTarget, Orientable

A box-like widget that can wrap into multiple lines.

<picture> <source srcset="wrap-box-dark.png" media="(prefers-color-scheme: dark)"> <img src="wrap-box.png" alt="wrap-box"> </picture>

`AdwWrapBox` is similar to [class@Gtk.Box], but can wrap lines when the widgets cannot fit otherwise. Unlike [class@Gtk.FlowBox], the children aren't arranged into a grid and behave more like words in a wrapping label.

Like `GtkBox`, `AdwWrapBox` is orientable and has spacing:

  • [property@WrapBox:child-spacing] between children in the same line;
  • [property@WrapBox:line-spacing] between lines.

::: note Unlike `GtkBox`, `AdwWrapBox` cannot follow the CSS `border-spacing` property.

Use the [property@WrapBox:natural-line-length] property to determine the layout's natural size, e.g. when using it in a [ class@Gtk.Popover].

Normally, a horizontal `AdwWrapBox` wraps left to right and top to bottom for left-to-right languages. Both of these directions can be reversed, using the [property@WrapBox:pack-direction] and [property@WrapBox:wrap-reverse] properties. Additionally, the alignment of each line can be controlled with the [property@WrapBox:align] property.

Lines can be justified using the [property@WrapBox:justify] property, filling the entire line by either increasing child size or spacing depending on the value. Set [property@WrapBox:justify-last-line] to justify the last line as well.

By default, `AdwWrapBox` wraps as soon as the previous line cannot fit any more children without shrinking them past their natural size. Set [property@WrapBox:wrap-policy] to [enum@Adw.WrapPolicy.minimum] to only wrap once all the children in the previous line have been shrunk to their minimum size.

To make each line take the same amount of space, set [property@WrapBox:line-homogeneous] to `TRUE`.

Spacing and natural line length can scale with the text scale factor, use the [property@WrapBox:child-spacing-unit], [ property@WrapBox:line-spacing-unit] and/or [property@WrapBox:natural-line-length-unit] properties to enable that behavior.

See [class@WrapLayout].

CSS nodes

`AdwWrapBox` uses a single CSS node with name `wrap-box`.

Accessibility

`AdwWrapBox` uses the [enum@Gtk.AccessibleRole.group] role.


Namespace: Adw
Package: libadwaita-1

Content:

Properties:

Creation methods:

Methods:

Inherited Members:

All known members inherited from class Gtk.Widget
All known members inherited from interface Gtk.Orientable