Text & Input SwiftUI reference
Focused SwiftUI text & input pages with original examples, usage guidance, and implementation notes.
Style Text with dynamic type styles, fontWeight, fontDesign, and fontWidth; load custom fonts with relative scaling so typography still respects accessibility.
Pass format styles directly to Text — currencies, percents, dates, measurements, lists, and even live timers — and get localization for free.
Control how text behaves under pressure: lineLimit and reserved space, minimumScaleFactor shrinking, truncationMode, tightening, and line spacing.
Text literals parse Markdown — bold, italics, code, links — while AttributedString unlocks programmatic runs, custom attributes, and styled interpolation.
TextField binds editable text with a placeholder label, keyboardType for input-appropriate keys, textContentType for autofill, and capitalization and autocorrection control.
@FocusState moves the cursor programmatically, onSubmit chains fields through return, and onChange validates as users type — the wiring of real forms.
SecureField masks input for secrets, pairs with textContentType for password managers and strong-password suggestions, and composes with TextField for reveal toggles.
TextEditor binds long-form scrolling text. Style with font and lineSpacing, restyle backgrounds via scrollContentBackground, and manage the keyboard with focus and toolbars.