MoneyInput
HkMoneyInput is a currency-aware amount field whose model is canonical decimal text — "", "12", "1.5", "-0.25": ASCII digits, at most one dot, no grouping, no symbol. The host owns that string; the component only converts between it and the human text in the box. Grouping and fixed precision appear on blur, canonical text returns on focus, and the element is never rewritten under the caret mid-typing.
There is no Rust mirror of this component; it is Vue-only.
- A plain, non-monetary value is an HkInput — it has no precision budget, no symbol and no range message.
- A token budget ("128K", "1.5M") with a unit picker is HkTokenInput; it works on an absolute number, not decimal text.
- A field that mixes literal text with {{ token }} placeholders is HkTemplateField.
Import
;
The integration point is modelValue + @update:modelValue: the host stores the canonical string and writes it back. min / max are advisory — an out-of-range amount is reported through the localized range message and is never clamped behind the user's back.
Currency and precision
currency supplies the field's symbol (the code when the currency has no symbol), the default precision (currency.decimals) and the formatting of the range message; omit it and the field is a bare two-decimal number. maxDecimals raises the fraction budget above the currency's own — the per-million rate case — and is both the blur precision and the rounding budget.
Type 1234.5 and leave the field: it becomes $1,234.50, while the model stays "1234.5". Focus it again and the box shows the editable canonical text.
Range and error
With min / max an out-of-range amount gets the localized range message under the field, and required marks the caption. error replaces any internal message with the host's own — the box takes its error face, the input publishes aria-invalid="true" and the caption line is linked through aria-describedby.
This account cannot hold a balance
Sizes and disabled
Three heights — sm, md (the default), lg — through the size prop; disabled greys the box out and takes the input out of the tab order. An empty string is a first-class value ("unset"): it is never coerced to 0.
API
Vue
Props
| Name | Type | Default | Required |
|---|---|---|---|
| modelValue | String | "" | — |
| currency | Object as PropType<HkCurrency> | undefined | — |
| maxDecimals | Number | undefined | — |
| min | Number | undefined | — |
| max | Number | undefined | — |
| label | String | undefined | — |
| error | String | undefined | — |
| disabled | Boolean | false | — |
| required | Boolean | false | — |
| placeholder | String | "" | — |
| size | <code>String as PropType<"sm" | "md" | "lg"></code> | "md" | — |
| id | String | undefined | — |
Emits
| Event | Payload |
|---|---|
| update:modelValue | string |
Accessibility
- The visible label is wired with for / id (an id is generated when the host passes none), so a click on the caption focuses the field and screen readers announce it by name.
- aria-invalid="true" follows the error state, and the rendered error line is linked through aria-describedby; the line also carries role="alert", so a message that appears after a blur is announced.
- The element is a plain text field with inputmode="decimal" — a decimal keypad on touch, while required and disabled stay native attributes.
- The prefix symbol is aria-hidden, so the accessible value is the number, not the currency glyph.
Related components
- HkTokenInput — a token budget with a unit picker, over an absolute number.
- HkTagInput — a tag field whose value is an ordered key array.
- HkTemplateField — the editor for {{ token }} fill templates.
- HkTemplateText — the read-only rendering of a fill template.