I want typed numeric input fields with units
Submitted by Christoph Päper
Permalink https://webwewant.fyi/wants/bd9677b9-2a64-4f48-ab7f-4e581e7557ff/
This idea is currently being discussed.
I want a native HTML input type that accepts a numeric value together with a unit, and automatically converts the entered value to a canonical unit for form submission. Currently, <input type="number"> accepts only a bare number with no unit awareness, forcing authors to either use a separate unit selector or restrict users to a single unit system.
A dedicated amount input type would let users enter values in their preferred units — metric or imperial, for example — while the browser handles conversion and normalization transparently. Authors declare the canonical submission unit using a dedicated unit attribute; value may use any compatible unit as the initial display value, and step defines the stepping granularity in its own unit without implying the submission unit:
<input type="amount" unit="kg" value="10 lb" step="0.5 lb">
<input type="amount" unit="cm" step="1 cm">The browser would allow the user to type in any compatible unit (e.g., pounds when unit="kg"), then normalize and submit the value in the declared canonical unit. When value is omitted the control still uses the declared unit for parsing, validation, and submission. Compound measurements like 5 ft 10 in should also be supported for height, distance, and similar fields.
This builds on the idea of an amount element for localizing numeric data (see related link) but focuses on form input and submission rather than display-only rendering. Benefits include:
- Users in different locales can enter values in their familiar units without manual conversion.
- Authors can declare a canonical submission unit without writing conversion logic.
- Accessibility is improved because the semantic meaning of the number (quantity + dimension) is conveyed natively to assistive technologies.
- Validation becomes more meaningful: the browser can reject out-of-range values regardless of which unit the user typed.
- Votes
- 0
What are votes for and how are they tallied?