Indent / pad text in TextEditor
04:14 13 Jan 2023

I'm using both TextField and TextEditor, as I need single and multi-line text input. I'm targeting iOS 15+, so can't just use TextField with linelimit, as it's iOS 16+.

TextField("placeholder", text: "Hello world")
    .padding(10)

TextEditor(text: "Hello world")
    .frame(height: 100)
    .cornerRadius(14)

See this image:

enter image description here

The TextField has the text slightly indented, compared with the TextEditor. How do I indent the TextEditor input text? I've tried using .padding but can't find a way to get it to just target the text — I'm only able to pad the frame of the editor.

swift swiftui