<!--
{
  "documentType" : "article",
  "framework" : "Security",
  "identifier" : "/documentation/Security/enabling-password-autofill-on-a-text-input-view",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Enabling Password AutoFill on a text input view"
}
-->

# Enabling Password AutoFill on a text input view

Make sure a text input view displays the correct AutoFill suggestions.

## Discussion

To ensure your text input view displays the right AutoFill suggestions, set the <doc://com.apple.documentation/documentation/UIKit/UITextInputTraits/textContentType> property on any relevant input views.

Use the following <doc://com.apple.documentation/documentation/UIKit/UITextContentType> values:

|Credential   |`UITextContentType` value                                                        |
|-------------|---------------------------------------------------------------------------------|
|User name    |<doc://com.apple.documentation/documentation/UIKit/UITextContentType/username>   |
|Password     |<doc://com.apple.documentation/documentation/UIKit/UITextContentType/password>   |
|New password |<doc://com.apple.documentation/documentation/UIKit/UITextContentType/newPassword>|
|One-time code|<doc://com.apple.documentation/documentation/UIKit/UITextContentType/oneTimeCode>|

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 <doc://com.apple.documentation/documentation/UIKit/UITextContentType/username> and <doc://com.apple.documentation/documentation/UIKit/UITextContentType/password> types lets the user tap and fill those inputs, even if they’re on separate pages.

> Important:
> tvOS apps can also support Password AutoFill using the same content-type settings. The AutoFill QuickType bar appears above the keyboard when entering passwords with an iOS device using the Control Center keyboard, the Remote app, or the Continuity Keyboard. Focus is also advanced to the login button when the login fields are populated.

By default, the system selects a keyboard based on the input view’s <doc://com.apple.documentation/documentation/UIKit/UITextInputTraits/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 <doc://com.apple.documentation/documentation/UIKit/UITextInputTraits/textContentType> property to <doc://com.apple.documentation/documentation/UIKit/UITextContentType/username>, and set the <doc://com.apple.documentation/documentation/UIKit/UITextInputTraits/keyboardType> property to <doc://com.apple.documentation/documentation/UIKit/UIKeyboardType/emailAddress>.

> Note:
> Leverage the system keyboard rather than implementing a keyboard directly in your app’s view hierarchy.

This example defines text fields for logging in:

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

When creating a new account or changing the password, use the <doc://com.apple.documentation/documentation/UIKit/UITextContentType/newPassword> text content type instead:

```swift
newPasswordTextField.textContentType = .newPassword
confirmPasswordTextField.textContentType = .newPassword
```

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

```swift
singleFactorCodeTextField.textContentType = .oneTimeCode
```

iOS supports Password AutoFill on <doc://com.apple.documentation/documentation/UIKit/UITextField>, [UITextView](https://developer.apple.com/library/archive/releasenotes/iPhone/RN-iPhoneSDK/index.html#//apple_ref/doc/uid/TP40007428-CH1-SW14), and any custom view that adopts the <doc://com.apple.documentation/documentation/UIKit/UITextInput> protocol.

> Warning:
> If you use a custom input view for a security code input text field, iOS can’t display the necessary AutoFill UI.

For more information on how to enable Password AutoFill behavior in web apps, see [Enabling Password AutoFill on an HTML input element](/documentation/Security/enabling-password-autofill-on-an-html-input-element).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)