Skip to main content
.multilineTextAlignment(alignment: TextAlignment): Component
alignment
TextAlignment
required
The horizontal alignment for multi-line text. One of "leading", "center", or "trailing".

Support

Usage

Center-aligned text

Text("This is a longer piece of text that will wrap to multiple lines and be centered.")
    .multilineTextAlignment("center")
    .frame({ maxWidth: 250 })

Trailing-aligned text

Text("Right-aligned text\non multiple lines")
    .multilineTextAlignment("trailing")

Combined with frame alignment

Text("Centered text in a full-width frame")
    .multilineTextAlignment("center")
    .frame({ maxWidth: Infinity, alignment: "center" })

Notes

  • This modifier only affects text that wraps to multiple lines. Single-line text alignment is controlled by the parent container’s alignment or the .frame() alignment.
  • The default alignment is "leading".

See Also