[Feedback Requested] Cross-platform Adaptation for Text Field #95
InMatrix
started this conversation in
Cross-platform Design
Replies: 2 comments 2 replies
-
When will the Text Field adaptive api be added |
Beta Was this translation helpful? Give feedback.
2 replies
-
Looking forward to adding it, along with more adaptive apis, to add a better user experience |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What is a text field?
Text fields, usually rectangular areas, allow users to enter text into a UI. They typically appear in forms and dialogs.
Platform differences
Since Android 12, the default UI of text fields follows the design guidelines defined in Material 3 (M3). On iOS, an equivalent component is defined in Human Interface Guidelines (HIG). There are some notable differences on the design of text fields between the two platforms.
Text fields on Android
On Android, Material Design text fields come in two basic styles: filled and outlined (see the screenshot below). They are more colorful and visually prominent than their iOS counterparts.
Text fields on iOS
On iOS, text fields are unstyled by default, as you can see from the UI for entering recipients in the Messages app.
It’s common to add thin gray borders to text fields in iOS apps. An example is the UI for entering message content in the Messages app. Rounded corners are used in the example, but they’re not inherently required by iOS. The examples in the text field’s HIG article do not have rounded corners.
The search field on iOS is a text field with a particular style. It has a filled background, rounded corners, but no border color. It also includes both leading and trailing icons in the text field.
Text fields in Flutter
The Flutter framework has two different widgets for displaying alert dialogs:
Adaptation recommendation
Our general recommendation is to follow the platform convention when using text fields in your app, because the default look of Material Design text fields has unusually prominent visual features and colors than most text fields on iOS. Switching to the
CupertinoTextField
is one way to do that, but you could also customize theTextField
widget in thematerial
library to achieve similar results with the benefits of sticking with the same API and having more customization options. Note that Flutter automatically adapts detailed interactions with text such as spell check and text selection to the target platform for theTextField
widget.The code snippets below show you how to do that, and you can see these two examples in action in DartPad.
Example code: basic text fields adaptive to iOS and Android
The code snippet below implements a basic text field showing a platform-specific UI through customizing
TextField
.Example code: search fields adaptive to iOS and Android
The code snippet below implements a search field showing a platform-specific UI through customizing
TextField
.Output on iOS:
Output on Android:
Beta Was this translation helpful? Give feedback.
All reactions