Input
HkInput is the shared text-field shell of the design system: a caption, a bordered box, an optional affix on either side, the native field and a message line — all of it wired for forms (label / for, required, error, hint, submitOnEnter). It renders either an <input> or, with type="textarea", a <textarea> inside the same chrome. Reach for it for any free-text entry that needs a label or a validation message.
- For a plain multi-line editor with a character counter and no caption chrome, use HkTextarea.
- For a field whose only job is filtering a list, use HkSearchInput.
- For a numeric field with the ± stepper column, use HkNumberInput.
Import
;
use *; // Input, InputSize, InputVariant, InputAlign
use *; // rsx!, VNode, Icon, MdiIcon
The Rust form is a plain function, Input(InputProps { … }). Every prop may be omitted inside rsx!, and an omitted prop takes its default. The Vue form is controlled (modelValue + update:modelValue); the Rust form is a still, so its examples pass the value the field holds.
Sizes
Three steps, sm / md (the default) / lg, carried by hk-input-box-{size}: they set the box height, the padding and the font size together.
Caption, hint and error
label renders the caption above the box; hint is the quiet line under it, and error replaces that line and turns the box red. required appends the * marker to the caption. hideLabel keeps the caption out of sight but keeps it semantic — the field then carries it as its aria-label.
We only use it for receipts.
Enter a valid address.
Affixes and alignment
#prefix / #suffix put arbitrary content inside the box, and #prefixIcon / #suffixIcon are their glyph-only shorthand; a slot always beats the icon. align chooses where the text line sits: center (the default) reserves room for both affixes symmetrically so the caret stays on the box axis, while start and end pad only the affix that is actually there.
The Rust mirror takes the same four slots as element props, where a slot wins over its icon exactly like Vue.
Variants and states
variant="number" maps the element to type="number" and hides the native spin buttons. In the Rust mirror the variant is class-only: it keeps that marker behaviour but ships no ± stepper column — a numeric field with steps is HkNumberInput's job; type="textarea" swaps the element for a <textarea> inside the same box, with rows and autoGrow deciding its height. disabled and readonly are the native states — a disabled field is dimmed and skipped by the Tab order, a read-only one still takes focus so its text can be selected and copied.
Whole units only.
Copy it with Ctrl+C.
API
Vue
Props
| Name | Type | Default | Required |
|---|---|---|---|
| modelValue | String | "" | — |
| type | String | "text" | — |
| placeholder | String | "" | — |
| label | String | undefined | — |
| error | String | undefined | — |
| hint | String | undefined | — |
| disabled | Boolean | false | — |
| readonly | Boolean | false | — |
| required | Boolean | false | — |
| name | String | undefined | — |
| id | String | undefined | — |
| spellcheck | Boolean | undefined | — |
| submitOnEnter | Function as PropType<() => void> | undefined | — |
| autocomplete | String | undefined | — |
| rows | Number | 3 | — |
| autoGrow | Boolean | false | — |
| autoGrowMax | Number | undefined | — |
| size | <code>String as () => "sm" | "md" | "lg"</code> | "md" | — |
| hideLabel | Boolean | false | — |
| variant | <code>String as () => "text" | "password" | "number"</code> | "text" | — |
| passwordTrailing | <code>String as () => "eye" | "strength" | "none"</code> | "eye" | — |
| revealStrategy | <code>String as () => "filter" | "sweep" | "noise" | "plain"</code> | "filter" | — |
| revealTrigger | <code>String as () => "hold" | "toggle"</code> | "hold" | — |
| revealAutoHideMs | Number | 8000 | — |
| strengthEvaluator | Function as PropType<PasswordStrengthEvaluator> | undefined | — |
| align | <code>String as () => "center" | "start" | "end"</code> | "center" | — |
| placeholderVariant | <code>String as () => "marquee" | "truncate"</code> | "marquee" | — |
Emits
| Event | Payload |
|---|---|
| update:modelValue | string |
| focus | FocusEvent |
| blur | FocusEvent |
| keydown | KeyboardEvent |
Rust
Props — Input
| Prop | Type | Default | Description |
|---|---|---|---|
| model_value | String | "" | Vue: modelValue, default "". |
| value | Option<String> | None | Pre-mirror alias of InputProps::model_value; wins when Some. |
| input_type | Option<String> | None | Vue's type ("text", "number", "textarea", …); None renders "text". |
| placeholder | Option<String> | None | Native placeholder. |
| label | Option<String> | None | Caption above the box (Vue: label, default undefined). |
| error | Option<String> | None | Error ink + message line; wins over InputProps::hint. |
| hint | Option<String> | None | Secondary message line, shown only when there is no error. |
| disabled | bool | false | — |
| readonly | bool | false | — |
| required | bool | false | Appends the * marker to the caption (Vue: required). |
| name | Option<String> | None | Native name attribute. |
| id | Option<String> | None | Element id the caption's for points at (Vue: id, useId() when omitted — no Rust analogue, see the header deltas). |
| spellcheck | Option<bool> | None | Native spellcheck toggle; None keeps the browser default. |
| submit_on_enter | Option<EventHandler<()>> | None | Submit intent on a modifier-free Enter (Vue: submitOnEnter). |
| autocomplete | Option<String> | None | Native autocomplete; None renders "off" (Vue's ?? "off"). |
| autofocus | bool | false | Focus the field on mount (Vue leaves this to the attrs spread). |
| rows | u32 | 3 | Textarea row count (Vue: rows, default 3). |
| auto_grow | bool | false | Textarea auto-grow opt-in (Vue: autoGrow); adds the data-autogrow box marker and the element's autogrow class. |
| size | InputSize | InputSize::Medium | Size step (hk-input-box-{size}). |
| hide_label | bool | false | Keep label semantic but off screen: the element gets aria-label={label} instead (Vue: hideLabel). |
| variant | InputVariant | InputVariant::Text | Input variant; number maps the element type. |
| align | InputAlign | InputAlign::Center | Text-line alignment (data-align). |
| prefix | Option<Element> | None | Affix slot (Vue: #prefix); wins over InputProps::prefix_icon. |
| prefix_icon | Option<Element> | None | Icon affix (Vue: #prefixIcon). |
| suffix | Option<Element> | None | Affix slot (Vue: #suffix); wins over InputProps::suffix_icon. |
| suffix_icon | Option<Element> | None | Icon affix (Vue: #suffixIcon). |
| class | String | "" | — |
| oninput | Option<EventHandler<String>> | None | Fires with the field's new text (Vue: update:modelValue). |
| onfocus | Option<EventHandler<FocusEvent>> | None | Vue: the focus emit. |
| onblur | Option<EventHandler<FocusEvent>> | None | Vue: the blur emit. |
| onkeydown | Option<EventHandler<KeyboardEvent>> | None | Vue: the keydown emit (after the submit-on-Enter interception). |
| onchange | Option<EventHandler<ChangeEvent>> | None | Vue: the change emit (a listener the attrs spread brings along). |
| attrs | Vec<(String, String)> | [] | Attributes set on the field element by name, after the component's own — maxlength, min, step, title, data-*, aria-*, test hooks (Vue: the attrs spread on the element). |
| bare | bool | false | Render the field element alone: no caption, box, affixes or message line, class on the element and none of the sheet's own classes — the host draws the chrome and keeps the event wiring. |
| glow | bool | false | Retired glow toggle; the Vue sheet owns the field chrome. |
| glow_blur | GlowBlur | GlowBlur::Medium | Retired glow blur step. |
| glow_color | GlowColor | GlowColor::Ghost | Retired glow ink. |
| glow_intensity | GlowIntensity | GlowIntensity::Soft | Retired glow intensity. |
Accessibility
- The caption is a real <label> whose for points at the field. In Vue the field id is generated with useId() when id is omitted, so a bare label is associated with no caller effort; the Rust mirror generates no id, so pass id when a caption and its field must be programmatically bound.
- hideLabel does not remove the name: the field then carries aria-label={label} instead of a visible caption.
- error is announced as text under the field; wire it to your own aria-describedby if you need the association to survive a re-render, and keep required on the field so screen readers announce it.
- Enter with no modifiers runs submitOnEnter — except for a textarea, where Enter is the native newline unless submitOnEnter was given. The field then keeps its focus; the browser's implicit form submission is prevented first.
- autocomplete="off" is the default, and the fields that opt out of password-manager fills (data-1p-ignore / data-lpignore) do so on their own element.
Related components
- HkTextarea — the same editor without the caption and affix chrome, plus a character counter.
- HkSearchInput — the bare search field with a leading magnifier and a clear button.
- HkNumberInput — a numeric field with a stepper column and in-field affixes.
- HkPhoneInput — an Input whose leading affix is a country dial-code picker.
- HkOtpInput — one cell per character for one-time codes.