How To Change Keyboard Type In SwiftUI

SwiftUI has a new TextEditor and old TextField for user inputs.

Be default they have a standard keyboard. However, if you want to switch to another like numeric, email, or twitter keyboard you can do it.

There is .keyboardType view modifier that takes one of few possible options.

TextEditor(text: $text)
    .
keyboardType(.numberPad)

Other possible options are:

-asciiCapable
-numbersAndPunctuation
-URL
-numberPad
-phonePad
-namePhonePad
-emailAddress
-decimalPad
-twitter
-webSearch
-asciiCapableNumberPad
-alphabet – deprecated