question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support `inputmode` attribute in `Input` components

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

Summary 💡

inputmode is a HTML5 attribute for input tags allows the browser to hint at which type of keyboard (on mobile devices) it should pop up: text, numeric, decimal

Its advantage on type="number" is summed up by the spec:

The type=number state is not appropriate for input that happens to only consist of numbers but isn’t strictly speaking a number. For example, it would be inappropriate for credit card numbers or US postal codes. A simple way of determining whether to use type=number is to consider whether it would make sense for the input control to have a spinbox interface (e.g., with “up” and “down” arrows). Getting a credit card number wrong by 1 in the last digit isn’t a minor mistake, it’s as wrong as getting every digit incorrect.

Its browser support is not that great however:

image

Examples 🌈

Try out this codesandbox on mobile to see an input with type="text" pop up the numeric keyboard on mobile.

Motivation 🔦

I’m trying to have a TextField component pop up a numeric keyboard on mobile without coercing the value inside the field to a number (which does not work in my case as we manipulate a comma-separated decimal in our French locale).

Should there be enough support for this feature request, I’d be happy to take care of it!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

12reactions
oliviertassinaricommented, Aug 31, 2021

@phacks Does it solve the problem?

<TextField inputProps={{ inputMode: 'numeric' }} />
0reactions
git-allcardcommented, Aug 31, 2021
inputProps={{ inputMode: 'numeric' }

Until now it’s not working.

<TextField id = “age” label = “Age” variant = “outlined” placeholder=“Enter Your Age” fullWidth type=“number” inputProps={{ inputMode: ‘numeric’ }} margin = “normal” {…field} error={Boolean(errors?.ageField) } helperText={errors.ageField?.message} />

Read more comments on GitHub >

github_iconTop Results From Across the Web

inputmode - HTML: HyperText Markup Language | MDN
The inputmode global attribute is an enumerated attribute that hints at ... It is used primarily on <input> elements, but is usable on...
Read more >
Support inputmode attribute in Input components #17820
inputmode is a HTML5 attribute for input tags allows the browser to hint at which type of keyboard (on mobile devices) it should...
Read more >
HTML5 Forms: inputmode Attribute - Wufoo
The inputmode attribute tells the browser on devices with dynamic keyboards which keyboard to display. The inputmode attribute applies to the text, ...
Read more >
Everything You Ever Wanted to Know About inputmode
The inputmode global attribute provides a hint to browsers for devices with onscreen keyboards to help them decide which keyboard to display ...
Read more >
HTML inputmode Attribute - GeeksforGeeks
The inputmode is an HTML Global attribute (Global attributes are common to all HTML elements) which helps browsers or devices with on-screen ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found