Text SwiftUI

Text SwiftUI

  • Shrink component: Will shrink to fit, using wrap or truncate.

  • Used everywhere: labels, buttons, lists, etc.

  • Compare to UILabel (and maybe UITextView for line spacing.) SwiftUI Label is different than UILabel and includes text + image.

  • String (includes emoji)

  • Size (min size or intrinsic size), requires custom size to fit, scale to fit (custom max size).

  • Font (dynamic)

  • Color (dynamic foreground, background)


  • Text SwiftUI: Just .font modifier in List. 7 basic styles. +4
  • Text Scale To Fit SwiftUI
  • Text To Speech: Just code, no execution. Used in Fruits and Words.


Text Font SwiftUI

  • size: font styles (dynamic type)
  • weight: ultraLight-black
  • design: monospaced, rounded, serif
  • effects (format): bold, italic, underline, strikethrough
  • spacing

In most cases, just use font styles (semantic styles or dynamic type), and avoid hard code of size, weight, design, effects, etc.

Text Color SwiftUI

  • Foreground color (default color style primary,) dynamic color
  • Background color (default color style ??? background) dynamic color


  • lineLimit: Without limit wide strings will wrap. (Default is multiline.) With limit wide strings will truncate. In use case of labels prefer truncation to wrap. (May also want to increase width or reduce font.) Used in Words grid tiles. (And probably list rows too.)
  • fixedSize(horizontal: vertical:) Default is not fixed size. Text will wrap or truncate to fit.
  • multilineTextAlignment
  • truncationMode


  • No attributed string support.

Related To

  • TextField
  • TextEditor


  • Text To Speech
  • Size To Fit (scale to fit): minScaleFactor(0.01) + size(maximumSize=500)
  • Somewhere there is letter animation?

Apple Documentation https://developer.apple.com/documentation/swiftui/text https://developer.apple.com/documentation/swiftui/text/fixedsize()