Text Fields provides both a single-line version based on UITextField
and a multi-line version backed by UITextView
as well as objects that customize the text fields' behavior and appearance called ‘Text Input Controllers’.
The actual components (MDCTextField
& MDCMultilineTextField
) are ‘dumb’: they do not have styles, animations, or advanced features. They are designed to be controlled from the outside, via very liberal public API, with a text input controller.
Most text input controllers included are based on MDCTextInputControllerBase
which manipulates the exposed elements of the text field to make placeholders float.
There is also a text input controller for full-width forms (MDCTextInputControllerFullWidth
). Like MDCTextInputControllerBase
d controllers, it also handles errors and character counting but has not been thoroughly tested with UX research.
Customize the included text input controllers via their parameters or create your own to express your app's brand identity thru typography, color, and animation: if the placeholder should move, add constraints or change the frame. If the trailing label should display validation information, change the text and color it.
This pattern is not a delegation or data source-like relationship but rather a controller-to-view relationship: the text field does not require nor expect to be served data or instruction but is instead malleable and easily influenced by outside interference.