Skip to content

Number Input

@astryxdesign/core v0.7.1 · NumberInput

NumberInput Props ​

NameTypeDefaultDescription
modelValuenumber | nullnullCurrent value. An empty field is null.
labelstring—Field label, also used as the accessible name.
descriptionstring—Helper text under the label.
placeholderstring''Placeholder text.
minnumber | null—Minimum value. On blur or Enter, a smaller entry commits at this value. While typing, it is marked invalid.
maxnumber | null—Maximum value. On blur or Enter, a larger entry commits at this value. While typing, it is marked invalid.
stepnumber | null1Amount added or removed on each step.
hasNumberSteppersbooleanfalseShows increment and decrement buttons at the end of the input. A button is disabled when its step would not change the value.
isWheelEnabledbooleantrueWhether scrolling the wheel over the focused input steps the value. Turn it off where page scrolling should always win.
isIntegerOnlybooleanfalseOnly whole numbers commit. Decimal entries stay in the field while editing and are dropped when the field loses focus. The keyboard also switches to the numeric keypad.
formatValue(value: number) => string—Formats the value shown while the field is not focused, for example (v) => `${v} items`. Focus shows the raw number so it stays editable, and the formatted text is exposed through aria-valuetext.
unitsstring | null—Unit shown at the end of the input, such as %.
hasClearbooleanfalseShows a clear button when the field has a value. The tooltip only says “Clear”; the accessible name includes the field label. Clearing sets the value to null. An emptied draft commits null on blur only when this is on; otherwise it reverts.
isDisabledbooleanfalseDisables the field.
disabledMessagestring—Explains why the field is disabled. With isDisabled, the reason shows in a tooltip on hover and keyboard focus, and the input stays focusable through aria-disabled instead of being removed from the tab order.
isReadOnlybooleanfalseShows the value at full opacity and still submits it, but blocks edits. Arrow keys, the wheel, and the stepper buttons are all off while read-only. isDisabled wins when both are set.
isOptionalbooleanfalseMarks the field optional. Mutually exclusive with isRequired.
isRequiredbooleanfalseMarks the field required. Mutually exclusive with isOptional.
isLabelHiddenbooleanfalseKeeps the label for screen readers and hides it visually.
labelTooltipstring—Tooltip text behind an info icon at the end of the label.
labelIconComponent—Icon shown before the label text. The labelIcon slot works too.
startIconComponent—Icon shown at the start of the input. The icon slot works too.
size'sm' | 'md' | 'lg''md'Field size.
widthnumber | string—Width of the whole field, label and status included. Numbers are pixels, strings are used as-is, such as '100%'.
status'default' | 'error' | 'warning' | 'success' | { type, message? }—Validation status. An object with message shows that text under the field.
statusVariant'attached' | 'detached' | 'tooltip''attached'How the status message is placed. 'tooltip' hides the message box and reveals it from the status icon instead.
htmlNamestring—Form field name.
autoCompletestring—Native autocomplete attribute.
hasAutoFocusbooleanfalseFocuses the input after it mounts.
idstring—Id for the input element. Generated when omitted.
disabledbooleanfalseSame as isDisabled.
disabledReasonstring—Same as disabledMessage.
clearablebooleanfalseSame as hasClear.
namestring—Same as htmlName.
containerClassstring | object | array—Class for the field container. Has no effect, and warns in development, when no Field box renders, including inside InputGroup and a horizontal-labels FormLayout.
containerStyleStyleValue—Inline style for the field container.
controlClassstring | object | array—Class for the number field box. A class written on the component lands here too, with no warning.
controlStyleStyleValue—Inline style for the number field box. A style written on the component lands here too.

NumberInput events ​

NamePayloadDescription
update:modelValuevalue: number | nullEmitted when the value changes.
changevalue: number | nullEmitted when the value changes. null means the field was cleared.
focusevent: FocusEventEmitted when the input receives focus.
blurevent: FocusEventEmitted when the input loses focus.
enterevent: KeyboardEventEmitted when Enter is pressed in the input.
keydownevent: KeyboardEventEmitted on keydown in the input, before the arrow keys step the value. Calling preventDefault() keeps the value unchanged.

NumberInput slots ​

NameDescription
iconIcon at the start of the input.
labelIconIcon before the label text.