---
title: WKInterfaceTextField
framework: watchkit
role: symbol
role_heading: Class
path: watchkit/wkinterfacetextfield
---

# WKInterfaceTextField

An interface element that displays an editable text area.

## Declaration

```swift
class WKInterfaceTextField
```

## Overview

Overview Text fields gather text-based input from the user. The text field defines an area of editable text within your user interface, letting you create forms with multiple input fields.

When the user taps the text field, WatchKit displays the text input controller. Users can enter text by selecting one of the suggestions, or using dictation or Scribble. Users can also launch the Apple Continuity Keyboard, entering text from a nearby iOS device logged into the same iCloud account. Use text fields to gather short, specific pieces of information such as the user’s name, address, password, or credit card number. Identify the type of data using the text field’s content type, which allows the system to optimize the behavior of the text input controller and the Apple Continuity Keyboard. For more information, see Authenticating Users on Apple Watch. You can also describe the expected content to the user in the text field’s placeholder. Effective placeholders let you build a form that is both compact and easy to use. For general text input, consider using presentTextInputController(withSuggestions:allowedInputMode:completion:) or presentTextInputControllerWithSuggestions(forLanguage:allowedInputMode:completion:) instead. Call these methods to display the text input controller with the suggestions that you provide. Keep in mind that the system doesn’t provide the text input controller with a content type, so the system cannot optimize its behavior. Configure the Text Field As with other WatchKit interface objects, you should not subclass or create instances of this class. Instead, add a text field to your WatchKit App’s storyboard. The system then creates the text field when it loads the storyboard. Xcode also lets you configure the text field directly in the storyboard. The following table lists the attributes and their meaning.  |   |   |   |   |   |   |  To dynamically modify a text field at runtime, define an outlet in your interface controller and connect it to the corresponding text field in your storyboard. For example, define a property with the following syntax in your interface controller class: During your interface controller’s initialization, WatchKit creates a new instance of the WKInterfaceTextField class and assigns it to your outlet. At that point, you can use the object in your outlet to manage the text field. Receive Text Input To receive the text entered by the user, connect the text field in the storyboard to an action method defined in your interface controller. WatchKit calls the action method after the user dismisses the text input controller. The value parameter contains the string entered by the user. If the user cancels the text input controller, the value is nil.

## Topics

### Specifying the Content Type

- [setTextContentType(_:)](watchkit/wkinterfacetextfield/settextcontenttype(_:).md)
- [WKTextContentType](watchkit/wktextcontenttype.md)

### Setting the Text

- [setText(_:)](watchkit/wkinterfacetextfield/settext(_:).md)
- [setAttributedText(_:)](watchkit/wkinterfacetextfield/setattributedtext(_:).md)
- [setTextColor(_:)](watchkit/wkinterfacetextfield/settextcolor(_:).md)

### Setting a Placeholder

- [setPlaceholder(_:)](watchkit/wkinterfacetextfield/setplaceholder(_:).md)
- [setAttributedPlaceholder(_:)](watchkit/wkinterfacetextfield/setattributedplaceholder(_:).md)

### Configuring the Control

- [setEnabled(_:)](watchkit/wkinterfacetextfield/setenabled(_:).md)
- [setSecureTextEntry(_:)](watchkit/wkinterfacetextfield/setsecuretextentry(_:).md)

## Relationships

### Inherits From

- [WKInterfaceObject](watchkit/wkinterfaceobject.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Related Documentation

- [presentTextInputController(withSuggestions:allowedInputMode:completion:)](watchkit/wkinterfacecontroller/presenttextinputcontroller(withsuggestions:allowedinputmode:completion:).md)
- [presentTextInputControllerWithSuggestions(forLanguage:allowedInputMode:completion:)](watchkit/wkinterfacecontroller/presenttextinputcontrollerwithsuggestions(forlanguage:allowedinputmode:completion:).md)

### Controls

- [WKInterfaceLabel](watchkit/wkinterfacelabel.md)
- [WKInterfaceDate](watchkit/wkinterfacedate.md)
- [WKInterfaceTimer](watchkit/wkinterfacetimer.md)
- [WKInterfaceButton](watchkit/wkinterfacebutton.md)
- [WKInterfaceAuthorizationAppleIDButton](watchkit/wkinterfaceauthorizationappleidbutton.md)
- [WKInterfacePaymentButton](watchkit/wkinterfacepaymentbutton.md)
- [WKInterfaceSwitch](watchkit/wkinterfaceswitch.md)
- [WKInterfaceSlider](watchkit/wkinterfaceslider.md)
- [WKInterfaceActivityRing](watchkit/wkinterfaceactivityring.md)
- [WKInterfaceMap](watchkit/wkinterfacemap.md)
