Input

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

tsx
1
import { HkInput } from "@celestia-island/hikari";
rust
1
2
use hikari_components::*;          // Input, InputSize, InputVariant, InputAlign
use hikari_components::prelude::*; // 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.

https://.app

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

NameTypeDefaultRequired
modelValueString""—
typeString"text"—
placeholderString""—
labelStringundefined—
errorStringundefined—
hintStringundefined—
disabledBooleanfalse—
readonlyBooleanfalse—
requiredBooleanfalse—
nameStringundefined—
idStringundefined—
spellcheckBooleanundefined—
submitOnEnterFunction as PropType<() => void>undefined—
autocompleteStringundefined—
rowsNumber3—
autoGrowBooleanfalse—
autoGrowMaxNumberundefined—
size<code>String as () => "sm" | "md" | "lg"</code>"md"—
hideLabelBooleanfalse—
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"—
revealAutoHideMsNumber8000—
strengthEvaluatorFunction as PropType<PasswordStrengthEvaluator>undefined—
align<code>String as () => "center" | "start" | "end"</code>"center"—
placeholderVariant<code>String as () => "marquee" | "truncate"</code>"marquee"—

Emits

EventPayload
update:modelValuestring
focusFocusEvent
blurFocusEvent
keydownKeyboardEvent

Rust

Props — Input

PropTypeDefaultDescription
model_valueString""Vue: modelValue, default "".
valueOption<String>NonePre-mirror alias of InputProps::model_value; wins when Some.
input_typeOption<String>NoneVue's type ("text", "number", "textarea", …); None renders "text".
placeholderOption<String>NoneNative placeholder.
labelOption<String>NoneCaption above the box (Vue: label, default undefined).
errorOption<String>NoneError ink + message line; wins over InputProps::hint.
hintOption<String>NoneSecondary message line, shown only when there is no error.
disabledboolfalse—
readonlyboolfalse—
requiredboolfalseAppends the * marker to the caption (Vue: required).
nameOption<String>NoneNative name attribute.
idOption<String>NoneElement id the caption's for points at (Vue: id, useId() when omitted — no Rust analogue, see the header deltas).
spellcheckOption<bool>NoneNative spellcheck toggle; None keeps the browser default.
submit_on_enterOption<EventHandler<()>>NoneSubmit intent on a modifier-free Enter (Vue: submitOnEnter).
autocompleteOption<String>NoneNative autocomplete; None renders "off" (Vue's ?? "off").
autofocusboolfalseFocus the field on mount (Vue leaves this to the attrs spread).
rowsu323Textarea row count (Vue: rows, default 3).
auto_growboolfalseTextarea auto-grow opt-in (Vue: autoGrow); adds the data-autogrow box marker and the element's autogrow class.
sizeInputSizeInputSize::MediumSize step (hk-input-box-{size}).
hide_labelboolfalseKeep label semantic but off screen: the element gets aria-label={label} instead (Vue: hideLabel).
variantInputVariantInputVariant::TextInput variant; number maps the element type.
alignInputAlignInputAlign::CenterText-line alignment (data-align).
prefixOption<Element>NoneAffix slot (Vue: #prefix); wins over InputProps::prefix_icon.
prefix_iconOption<Element>NoneIcon affix (Vue: #prefixIcon).
suffixOption<Element>NoneAffix slot (Vue: #suffix); wins over InputProps::suffix_icon.
suffix_iconOption<Element>NoneIcon affix (Vue: #suffixIcon).
classString""—
oninputOption<EventHandler<String>>NoneFires with the field's new text (Vue: update:modelValue).
onfocusOption<EventHandler<FocusEvent>>NoneVue: the focus emit.
onblurOption<EventHandler<FocusEvent>>NoneVue: the blur emit.
onkeydownOption<EventHandler<KeyboardEvent>>NoneVue: the keydown emit (after the submit-on-Enter interception).
onchangeOption<EventHandler<ChangeEvent>>NoneVue: the change emit (a listener the attrs spread brings along).
attrsVec<(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).
bareboolfalseRender 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.
glowboolfalseRetired glow toggle; the Vue sheet owns the field chrome.
glow_blurGlowBlurGlowBlur::MediumRetired glow blur step.
glow_colorGlowColorGlowColor::GhostRetired glow ink.
glow_intensityGlowIntensityGlowIntensity::SoftRetired 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.