NumberInput

NumberInput

HkNumberInput is the boxed numeric field: a native type="number" element with in-field prefix and suffix affixes, bounded by min / max and guarded by the shared HkNumberSteppers column on the right. Values are clamped onto the declared bounds and never snapped onto the step grid. Reach for it for quantities, counts, prices in whole units — anything a user nudges by one.

  • For free-text entry that happens to look numeric, use HkInput.
  • For a slider-style picker with a visible range, use the slider family instead.
  • For a money field with a currency mask, wrap HkInput with a suffix and your own parser.

Import

tsx
1
import { HkNumberInput } from "@celestia-island/hikari";
rust
1
2
use hikari_components::*;          // NumberInput, NumberInputSize, NumberStepperDirection
use hikari_components::prelude::*; // rsx!, VNode

The Rust form is a plain function, NumberInput(NumberInputProps { … }). One naming difference: Vue calls the value modelValue (a required prop), the Rust mirror calls it value: f64 and defaults it to 0.0 so the props struct stays Default-constructible.

Bounds and step

min and max clamp every path — typing, the ± column and the native arrow keys — and each one also gates its end of the column: at max the up button greys out, at min the down button does. step is both the amount each press moves and the native step attribute.

Seats booked: 25

Affixes and sizes

prefix and suffix render text inside the field, flex-centered on either side of the input; in Vue the #prefix / #suffix slots win over the text props. size — sm / md / lg — is shared with the stepper column so the field and its buttons stay one block.

The Rust mirror takes the same two affixes as text props plus the slot props prefix_slot / suffix_slot, which win in the same order.

pcs
kg
¥

States and bounds

A disabled field dims the box, the affixes and the whole stepper column at once, so nothing about it reads as pressable. A field held at a bound shows only one live half of the column.

API

Vue

Props

NameTypeDefaultRequired
modelValueNumber0—
minNumberundefined—
maxNumberundefined—
stepNumber1—
disabledBooleanfalse—
placeholderStringundefined—
labelStringundefined—
idStringundefined—
prefixStringundefined—
suffixStringundefined—
size<code>String as PropType<"sm" | "md" | "lg"></code>"md"—

Emits

EventPayload
update:modelValuenumber

Rust

Props — NumberInput

PropTypeDefaultDescription
valuef640.0Controlled value (Vue: modelValue, default 0).
minOption<f64>NoneLower bound; also the decrement dead end (Vue default undefined).
maxOption<f64>NoneUpper bound; also the increment dead end (Vue default undefined).
stepf641.0Step size used by the ± column and the native step attribute.
disabledboolfalse—
placeholderOption<String>NoneNative placeholder; None renders no attribute.
labelOption<String>NoneCaption above the box (Vue: label); empty means "no caption".
prefixOption<String>NoneIn-field affix text before the input (Vue: prefix).
suffixOption<String>NoneIn-field affix text after the input (Vue: suffix).
prefix_slotOption<Element>NoneVue: the #prefix slot — wins over NumberInputProps::prefix.
suffix_slotOption<Element>NoneVue: the #suffix slot — wins over NumberInputProps::suffix.
sizeNumberInputSizeNumberInputSize::MediumSize step (hk-number-input-{size}), shared with the step column.
idOption<String>NoneElement id; when present, the caption's for points at the field and the field carries the id (delta [D] — Vue leaves the caption unbound).
classString""Host class appended last (Vue attribute fallthrough).
styleString""Host style attribute (Vue attribute fallthrough).
oninputOption<EventHandler<f64>>NoneVue's update:modelValue — live, per keystroke and per step.
onchangeOption<EventHandler<f64>>NoneCommit channel (delta [D]): the field's native change (blur / Enter) and every step click, with the same clamped value as oninput.

Accessibility

  • The field is a native <input type="number">: assistive technology announces it as a spin button, the arrow keys step it natively and the native spin buttons are hidden by the stylesheet. An empty payload reads as 0, matching JavaScript's Number("").
  • The caption is bound: Vue generates the field id with useId() when id is omitted, and the Rust mirror emits for={id} and the field's own id when the host passes one. Pass label rather than a loose sibling text to keep the name attached.
  • The two step buttons are real buttons owned by HkNumberSteppers, and they render greyed at a dead end instead of disappearing — a bound is visible before it is hit.
  • In Rust the mirror splits Vue's single emit: oninput fires per accepted value, onchange only on a commit (blur, Enter, or a step press), both carrying the same clamped value.

Related components

  • HkInput — the general text field, with a number variant that drops the stepper column.
  • HkSearchInput — the bare search field.
  • HkPhoneInput — the phone field with a dial-code chip.
  • HkOtpInput — the one-time-code field.