Skip to main content
All CollectionsLayoutModifiers
Layout Priority Modifier
Layout Priority Modifier

Give the priority of space to a specific child in a layout.

Updated over 9 months ago

Layers typically have a default priority of 0, which causes space to be divided evenly to all sibling layers. Raising a layer’s Layout Priority encourages the higher priority layer to shrink later when the group is shrunk and stretch sooner when the group is stretched.

Take, for example, these two Text layers, embedded in an HStack.

At first, they are given an equal amount of space within the parent frame, but by giving the first layer a Layer Priority of 1, the second layer will shrink dramatically due to the higher priority of the first Text layer.

Note

A parent layout offers the child layers with the highest Layout Priority all the space offered to the parent minus the minimum space required for all its lower-priority children.

Did this answer your question?