number custom element renders a numeric input with optional prefix/suffix adornments, decimal precision, and range checks. Use it for merchant-defined quantities, monetary amounts, or rates.
Factory
Example
Options
NumberAdornment
'inset'overlays the adornment inside the input chrome. Best for short symbols ($,%).'tab'renders the adornment as a separate chip glued to one edge of the input. Best for short text labels (USD,kg).
Mode and precision
mode: 'integer'allows digits and a leading-only.mode: 'decimal'allows digits, a single., and a leading-.precisioncaps how many decimal places the input accepts. Characters past the cap are blocked while typing. AdefaultValuewhose decimal part exceeds the cap is truncated on the right at mount.precisiondoes not pad with trailing zeros. Values type-check asnumber, so the emitted value is exactly what shoppers see.
Range checks
min and max run when validate is not supplied. Empty inputs (null after parse) skip the range check; the required check owns emptiness. Providing validate skips every built-in check.
Value
null while the input is empty or mid-typing an incomplete number ('-', '.', '-.', '1.'). The next keystroke that resolves to a finite number flips value back to the parsed shape.
For arbitrary-precision arithmetic (currency rounding beyond four decimals), read element.value for the raw display string and apply your own decimal library downstream.