Home > OS >  How do you set placeholder text in a TextField to italics?
How do you set placeholder text in a TextField to italics?

Time:10-12

We can set italics on Text with the .italic() modifier, but how would you set italics in a TextField View for the placeholder text?

struct TextFieldItalics: View {
    @State private var username: String = ""
    
    var body: some View {
        VStack {
            Text("Hello, World!")
                .italic()
            TextField("Add username", text: $username)
        }
    }
}

enter image description here

CodePudding user response:

With font modifier:

.font(Font.body.italic())
  • Related