Declaration
compose().keyboardType(
type: 'default' | 'asciiCapable' | 'numbersAndPunctuation' | 'URL' | 'numberPad' | 'phonePad' | 'namePhonePad' | 'emailAddress' | 'decimalPad' | 'twitter' | 'webSearch' | 'asciiCapableNumberPad'
)nonisolated func keyboardType(_ type: UIKeyboardType) -> some ViewParameters
type*'default' | 'asciiCapable' | 'numbersAndPunctuation' | 'URL' | 'numberPad' | 'phonePad' | 'namePhonePad' | 'emailAddress' | 'decimalPad' | 'twitter' | 'webSearch' | 'asciiCapableNumberPad'One of the keyboard types defined in the
Discussion
Use keyboardType(_:) to specify the keyboard type to use for text
entry. A number of different keyboard types are available to meet
specialized input needs, such as entering email addresses or phone
numbers.
The example below presents a TextField to input an email address.
Setting the text field's keyboard type to .emailAddress ensures the
user can only enter correctly formatted email addresses.
TextField("someone@example.com", text: $emailAddress)
.keyboardType(.emailAddress)There are several different kinds of specialized keyboard types
available though the
doc://com.apple.documentation/documentation/UIKit/UIKeyboardType enumeration. To
specify the default system keyboard type, use .default.
doc://com.apple.documentation/documentation/UIKit/UIKeyboardType enumeration.
See also
More in Text and symbols.
- allowsTighteningSets whether text in this view can compress the space between characters when necessary to fit text in a line.
- autocorrectionDisabledSets whether to disable autocorrection for this view.
- baselineOffsetSets the vertical offset for the text relative to its baseline in this view.
- boldApplies a bold font weight to the text in this view.
- findDisabledPrevents find and replace operations in a text editor.
- findNavigatorProgrammatically presents the find and replace interface for text editor views.
- fontSets the default font for text in this view.
- fontDesignSets the font design of the text in this view.
- fontWeightSets the font weight of the text in this view.
- fontWidthSets the font width of the text in this view.
- interactionActivityTrackingTagSets a tag that you use for tracking interactivity.
- italicApplies italics to the text in this view.