Text Field
The following modifiers customize the behavior and appearance of TextField components. These allow you to control keyboard behavior, input handling, and submission logic.
onSubmit
Adds an action to perform when the user submits a value from the text field.
Type
Behavior
-
If provided as a function:
This is equivalent to:
-
You can explicitly define what kind of submission should trigger the action using the
triggersoption:
SubmitTriggers values:
"text": Triggered by text input views likeTextField,SecureField, etc."search": Triggered by search fields (e.g., those using thesearchablemodifier).
keyboardType
Specifies the type of keyboard to display when the text field is focused.
Type
Options
'default''numberPad''phonePad''namePhonePad''URL''decimalPad''asciiCapable''asciiCapableNumberPad''emailAddress''numbersAndPunctuation''twitter''webSearch'
Example
autocorrectionDisabled
Controls whether the system autocorrection is enabled.
Type
Default
true— autocorrection is disabled by default.
Example
textInputAutocapitalization
Sets how the text input system should automatically capitalize text.
Type
Options
"never"– No capitalization."characters"– All letters capitalized."sentences"– First letter of each sentence capitalized."words"– First letter of each word capitalized.
Example
submitScope
Prevents submission triggers from this view from propagating upward to parent views with submission handlers.
Type
Default
false— submission actions bubble up by default.
Example
This ensures that onSubmit handlers defined higher up in the view hierarchy won’t be called when this field is submitted.
submitLabel
Sets the label for the submit button.
