Enabling Password AutoFill on a Text Input View

Ensure a text input view displays the correct AutoFill suggestions.


To ensure your text input view displays the right AutoFill suggestions, set the textContentType property on any relevant input views.

Use the following UITextContentType values:


UITextContentType Value

User Name




New Password


One-Time Code


Explicitly defining a view’s text content type improves the performance of Password AutoFill’s heuristics and lets you support login workflows that couldn’t otherwise be detected by these heuristics. For example, the heuristics assume the user name and password inputs are on the same page. If you have a multipage login form, explicitly setting the .username and .password types lets the user tap and fill those inputs, even if they are on separate pages.

By default, the system selects the a keyboard based on the input view’s textContentType property; however, you can mix the input view’s text content type and keyboard type to explicitly define the desired keyboard. For example, if your site uses email addresses as user names, set the input view’s textContentType property to .username, and set the keyboardType property to .UIKeyboardType.emailAddress.

This example defines text fields for logging in:

userTextField.textContentType = .username
userTextField.keyboardType = .emailAddress
passwordTextField.textContentType = .password

When creating a new account or changing the password, use the .newPassword text content type instead:

newPasswordTextField.textContentType = .newPassword
confirmPasswordTextField.textContentType = .newPassword

Additionally, you can autocomplete security codes from single-factor SMS login flows:

singleFactorCodeTextField.textContentType = .oneTimeCode

iOS supports Password AutoFill on UITextField, UITextView, and any custom view that adopts the UITextInput protocol.

For more information on how to enable Password AutoFill behavior in web apps, see Enabling Password AutoFill on an HTML Input Element.

See Also

Modifying Text Input Views

var textContentType: UITextContentType!

Indicates the semantic meaning expected by a text-entry area.

static let username: UITextContentType

Specifies the expectation of an account or login name.

static let password: UITextContentType

Specifies the expectation of a password.

static let newPassword: UITextContentType

Specifies the expectation of a new password.

static let oneTimeCode: UITextContentType

Specifies the expectation of a single-factor SMS login code.