@@ -41,8 +41,7 @@ See [API](#api) for all available options.
41
41
- ** Beware of the ` number ` input type:** it may not be always what you want.
42
42
Not all number-like values are actually numbers, e.g. phone numbers, credit
43
43
card numbers, or business IDs. In such cases use the most appropriate input
44
- type (probably ` text ` or ` tel ` ) along with the
45
- [ ` pattern ` attribute] ( https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern )
44
+ type (probably ` text ` or ` tel ` ) along with the [ ` pattern ` attribute] [ pattern ]
46
45
to improve the input experience for touch users.
47
46
48
47
- Use ** short and descriptive labels** , ideally nouns rather than seemingly
@@ -64,9 +63,8 @@ See [API](#api) for all available options.
64
63
entered. Be positive and focus on solutions to make the error message helpful.
65
64
66
65
- When asking users for their contact information or other personal information,
67
- make use of the
68
- [ ` autocomplete ` attribute] ( https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete )
69
- to help them fill the form faster.
66
+ make use of the [ ` autocomplete ` attribute] [ autocomplete ] to help them fill the
67
+ form faster.
70
68
71
69
## Design Variants
72
70
@@ -183,14 +181,16 @@ individual text fields** using the `inputSize` property. It (obviously) sets the
183
181
` size ` attribute of the ` input ` element and is further picked up by CSS to
184
182
normalize rendering across browsers.
185
183
186
- 👉 Remember that the
187
- [ ` size ` ] ( https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text#size )
188
- HTML attribute ** does not limit on how many characters** the user can enter. Use
189
- the ` maxlength ` attribute to achieve that effect.
184
+ 👉 Remember that the [ ` size ` ] [ size ] and [ ` max ` ] [ max ] HTML attributes ** don't
185
+ limit on how many characters** the user can enter. Use the ` maxlength `
186
+ attribute to achieve that effect (doesn't work for ` number ` input type though).
190
187
191
- 👉 Note that according to the HTML specification, the ` inputSize ` option (which
192
- is translated as ` size ` attribute of the input element) is
193
- [ not available for the ` number ` input type] ( https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number#Controlling_input_size ) .
188
+ 👉 Note that according to the HTML specification, the ` size ` attribute (invoked
189
+ by ` inputSize ` API option) is
190
+ [ not available for ` number ` input type] [ input-number-size ] . TextField supports
191
+ ` inputSize ` option for all types of inputs, so you can use it whenever you find
192
+ it suitable. Just keep in mind the ` size ` attribute will not be present for
193
+ numeric inputs.
194
194
195
195
<Playground >
196
196
<TextField
@@ -202,6 +202,17 @@ is translated as `size` attribute of the input element) is
202
202
label = " Title"
203
203
variant = " filled"
204
204
/>
205
+ <TextField
206
+ inputSize = { 3 }
207
+ label = " Age"
208
+ type = " number"
209
+ />
210
+ <TextField
211
+ inputSize = { 3 }
212
+ label = " Age"
213
+ type = " number"
214
+ variant = " filled"
215
+ />
205
216
</Playground >
206
217
207
218
## Forwarding HTML Attributes
@@ -224,15 +235,26 @@ interfere with [component's API](#api) are forwarded to the native HTML input.
224
235
minLength = { 3 }
225
236
maxLength = { 80 }
226
237
/>
238
+ <TextField
239
+ inputSize = { 3 }
240
+ min = { 13 }
241
+ max = { 120 }
242
+ label = " Age"
243
+ type = " number"
244
+ />
245
+ <TextField
246
+ inputSize = { 3 }
247
+ min = { 13 }
248
+ max = { 120 }
249
+ label = " Age"
250
+ type = " number"
251
+ variant = " filled"
252
+ />
227
253
</Playground >
228
254
229
255
👉 Refer to the MDN reference for the full list of supported attributes of the
230
- [ text] ( https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text ) ,
231
- [ email] ( https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email ) ,
232
- [ number] ( https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number ) ,
233
- [ tel] ( https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/tel ) , and
234
- [ password] ( https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/password )
235
- input types.
256
+ [ text] [ input-text ] , [ email] [ input-email ] , [ number] [ input-number ] ,
257
+ [ tel] [ input-tel ] , and [ password] [ input-password ] input types.
236
258
237
259
## Invisible Label
238
260
@@ -355,9 +377,9 @@ filled.
355
377
</Playground >
356
378
357
379
Keep in mind that ** long help texts don't play well with small input sizes,**
358
- especially in a vertical layout. To fix this at least for the horizontal layout,
359
- the help text expands over the full field width when the desired input width
360
- (based on ` inputSize ` and ` max ` options ) is 10 characters or smaller.
380
+ especially in vertical layout. To fix this at least for horizontal layout, help
381
+ text expands over the full field width when the desired input width (based on
382
+ ` inputSize ` option ) is 10 characters or smaller.
361
383
362
384
<Playground >
363
385
<TextField
@@ -378,6 +400,7 @@ the help text expands over the full field width when the desired input width
378
400
layout = " horizontal"
379
401
min = { 13 }
380
402
max = { 120 }
403
+ inputSize = { 3 }
381
404
type = " number"
382
405
helpText = " How old do you see yourself?"
383
406
/>
@@ -386,6 +409,7 @@ the help text expands over the full field width when the desired input width
386
409
layout = " horizontal"
387
410
min = { 13 }
388
411
max = { 120 }
412
+ inputSize = { 3 }
389
413
variant = " filled"
390
414
type = " number"
391
415
helpText = " How old do you see yourself?"
@@ -476,5 +500,16 @@ This is useful mainly to improve component's
476
500
477
501
## Theming
478
502
479
- Head to [ Forms Theming] ( /customize/theming/forms ) to see shared form theming
480
- options.
503
+ Head to [ Forms Theming] [ theming-forms ] to see shared form theming options.
504
+
505
+ [ pattern ] : https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/pattern
506
+ [ autocomplete ] : https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete
507
+ [ size ] : https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text#size
508
+ [ max ] : https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number#max
509
+ [ input-number-size ] : https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number#Controlling_input_size
510
+ [ input-text ] : https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text
511
+ [ input-email ] : https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email
512
+ [ input-number ] : https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number
513
+ [ input-tel ] : https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/tel
514
+ [ input-password ] : https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/password
515
+ [ theming-forms ] : /customize/theming/forms
0 commit comments