frame sets fixed or flexible dimensions; containerRelativeFrame sizes a component relative to its nearest scrollable container; padding adds space around it.
offset shifts the visual position without affecting layout, zIndex controls stacking order inside a ZStack, and layoutPriority decides which sibling wins when space is tight.
frame
Sets the size of a component using fixed dimensions or flexible constraints.object
required
Fixed frame.
object
required
Flexible frame.
Infinity for maxWidth or maxHeight to make the component expand to fill all available space.
Fixed size
containerRelativeFrame
Sizes a component relative to its nearest container.Axis
required
Fill container overload: the axis along which the component fills the container. See Axis.
object
required
Grid subdivision overload.
object
required
Fractional sizing overload.
ScrollView, List, or NavigationStack. The modifier sizes the component relative to that container’s visible area, not the full scrollable content. The grid subdivision form calculates the cell width as: (containerWidth - (count - 1) * spacing) / count * span + (span - 1) * spacing.
Fill the container horizontally
padding
Adds padding around a component.number
The padding amount in points. When called with a single number, applies equal padding on all edges.
EdgeSet
Which edges to apply padding to. See EdgeSet. When omitted, padding is applied to all edges.
offset
Offsets the component’s visual position without affecting layout.object
required
The offset values in points.
zIndex
Controls stacking order in a ZStack.number
required
The stacking priority. Higher values render on top of lower values. The default is
0.zIndex only affects rendering order within the same parent container. Without it, components in a ZStack render in order: first child at the bottom, last child on top. Negative values are valid and place the component behind siblings with the default zIndex(0).
Bring a component to front
layoutPriority
Sets the layout priority for space distribution among siblings.number
required
The layout priority. Higher values receive preference for available space. Default is
0.HStack, VStack). All components default to a priority of 0. A component with priority 1 is offered its ideal size before components with priority 0. Negative values are valid and cause the component to shrink before siblings.
Prioritizing one text over another
When two texts compete for space in an HStack, the one with higher layout priority gets its full width before the other.
See also
- aspectRatio — sets the width-to-height ratio of content
- fixedSize — uses ideal size instead of the parent’s proposal
- Alignment — alignment values for
frameand corner-aligned overlays - Axis — axis values for
containerRelativeFrame - EdgeSet — edge values for
padding