Instructions
- Copy this file into the platform folder for this component
- Rename the file to "<platform>-text-field.md"
- Using text field
- Add a link under Using text field to your getting started page if you have one
- Insert installation and theming as appropriate for your platform
- Insert any additional instructions that apply to your platform with a separte level 3 header
- If you have no getting started links or instructions, delete the Using text field sections
- Filled text ane Outlined-text sections
- Add links to your platform
Text fields let users enter and edit text.
The text field class consists of the following types:
Text fields allow users to enter text into a UI. They typically appear in forms and dialogs.
Filled text fields have more visual emphasis than outlined text fields, making them stand out when surrounded by other content and components.
Source code API:
- <source class name>
- [Class definition](developer site here)
- GitHub source
The following examples shows a filled text field.
Copy the image to your platform's assets folder. Use a screenshot of your render.
* The label text should read "Label text"
* The input text should read "Input text"
* The helper text should read "Helper text"
* The text field should have a character counter of up to 20 characters
* The text field should have a "favorite" leading icon
- Container
- Leading icon (optional)
- Label text
- Input text
- Trailing icon (optional)
- Activation indicator
- Helper text (optional)
Container attributes
Attribute | Related method(s) | Default value | |
---|---|---|---|
<label> | |||
<label> | |||
<label> |
Leading icon (optional) attributes
Attribute | Related method(s) | Default value | |
---|---|---|---|
<label> | |||
<label> | |||
<label> |
Label text attributes
Attribute | Related method(s) | Default value | |
---|---|---|---|
<label> | |||
<label> | |||
<label> |
Input text attributes
Attribute | Related method(s) | Default value | |
---|---|---|---|
<label> | |||
<label> | |||
<label> |
Trailing icon (optional) attributes
Attribute | Related method(s) | Default value | |
---|---|---|---|
<label> | |||
<label> | |||
<label> |
Activation indicator attributes
Attribute | Related method(s) | Default value | |
---|---|---|---|
<label> | |||
<label> | |||
<label> |
Helper text (optional) attributes
Attribute | Related method(s) | Default value | |
---|---|---|---|
<label> | |||
<label> | |||
<label> |
Outlined text fields have less visual emphasis than filled text fields. When they appear in places like forms, where many text fields are placed together, their reduced emphasis helps simplify the layout.
Source code API:
- <source class name>
- [Class definition](developer site here)
- GitHub source
The following examples shows an outlined text field.
Copy the image to your platform's assets folder. Use a screenshot of your render.
* The label text should read "Label text"
* The input text should read "Input text"
* The error message text should read "Error message" and display the error message
* The text field should have a trailing error icon
- Container
- Leading icon (optional)
- Label text
- Input text
- Trailing icon (optional)
- Activation indicator
- Helper text (optional)
Container attributes
Attribute | Related method(s) | Default value | |
---|---|---|---|
<label> | |||
<label> | |||
<label> |
Leading icon (optional) attributes
Attribute | Related method(s) | Default value | |
---|---|---|---|
<label> | |||
<label> | |||
<label> |
Label text attributes
Attribute | Related method(s) | Default value | |
---|---|---|---|
<label> | |||
<label> | |||
<label> |
Input text attributes
Attribute | Related method(s) | Default value | |
---|---|---|---|
<label> | |||
<label> | |||
<label> |
Trailing icon (optional) attributes
Attribute | Related method(s) | Default value | |
---|---|---|---|
<label> | |||
<label> | |||
<label> |
Activation indicator attributes
Attribute | Related method(s) | Default value | |
---|---|---|---|
<label> | |||
<label> | |||
<label> |
Helper text (optional) attributes
Attribute | Related method(s) | Default value | |
---|---|---|---|
<label> | |||
<label> | |||
<label> |
Text fields support Material Theming and can be customized in terms of color, typography and shape.
API and source code:
\<Component platform API name\>
The following example shows filled and outlined text fields with Material Theming.
Implementing text field theming
Include source code for two side-by-side examples using a green/black color theme similar to the one used in the [Android button example](https://github.com/mingjane-work/doc-material-components/blob/mingjane-doc-branch/button-examples/Android/android-button-example.md):
* Include one filled text field with the following:
* The label text should read "Label text"
* The input text should read "Input text"
* The helper text should read "Helper text"
* The text field should have a character counter of up to 20 characters
* The text field should have a "favorite" leading icon
* The container should have cut corners instead of rounded
* Include one outlined text field with the following:
* The label text should read "Label text"
* The input text should read "Input text"
* The error message text should read "Error message" and display the error message
* The text field should have a trailing error icon
* The container should have cut corners instead of rounded