Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To allow a TextField to adjust its height automatically according to its content, set the .fixedSize(horizontal: false, vertical: true) modifier to it. This will cause the text field to wrap its contents vertically and grow or shrink dynamically based on the size of the text entered. For example:

TextField("Enter some text...", text: $text)
   .textFieldStyle(RoundedBorderTextFieldStyle())
   .fixedSize(horizontal: false, vertical: true)