'How do I create a multiline Textfiled in SwiftUI?

I am trying to achieve this view (on screenshot). The user can type in something inside this box. He should be able to make new paragraphs, but text should no longer be than the box's height, for example with linelimit. Goal: Goal

However, when selecting TextField, the line keeps growing horizontally while typing. I tried to modify by adding ".linelimit(nil) but it doesn't work. Another approach by me was using textEditor: with TextEditor and without padding

But there is also the problem with missing placeholder and modifications to layout and text padding. When I add padding, the layout looks like this:

with TextEditor and with padding.

This is my situation with TextEditor:

struct Notes: View {


@State private var notes = ""

var body: some View {
        VStack (alignment: .leading, spacing: 5) {
            Text("Notes")
                .fontWeight(.bold)
        TextEditor(text: $notes)
            .submitLabel(.done)
            //.padding()
            .frame(height: 100, alignment: .top)
            //.background(Color(.systemGray5))
            .lineLimit(3)
            .cornerRadius(22)
            .multilineTextAlignment(.leading)
            .colorMultiply(Color(.systemGray5))
        }
        .frame(minWidth: 0, maxWidth: .infinity)
        .padding(.horizontal)
}
}

Is there an alternative I am missing?

Thanks for any advice and help. Kind regards.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source