Skip to content
Latestv1.0.63

InputNumber ​

Allows input of standard numeric values within a defined range.

Basic Usage ​

Bind a variable with v-model, and use min and max attributes to limit the input range.

Basic Usage

Disabled State ​

Use the disabled attribute to disable the input field.

Disabled State

Step ​

Use the step attribute to control the step size.

Step

Precision ​

Use the precision attribute to control numeric precision.

Precision

Controls Position ​

Use controls-position="right" to place control buttons on the right.

Controls Position

Different Sizes ​

Use the size attribute to control the input size.

Different Sizes

Prefix and Suffix ​

Use prefix and suffix attributes to add prefix and suffix text.

Prefix and Suffix

Clearable ​

Use the clearable attribute to enable the clear button.

Clearable

Custom Validation ​

Use the validator attribute to define custom validation rules.

Custom Validation

Use in Nuxt ​

InputNumber fully supports Nuxt 3/4 SSR rendering. When used in a Nuxt project, the component is automatically imported.

Use in Nuxt

SSR Notes:

  • ✅ Basic numeric input and step calculations are fully supported.
  • ✅ Precision handling is formatted server-side.
  • ✅ Control button styles and positions are consistently supported in SSR.
  • ⚠️ Keyboard event listeners only take effect after client-side activation.

SSR Safety

InputNumber handles numeric precision and boundary constraints during the SSR phase, ensuring the values displayed on the first screen are as expected, avoiding hydration mismatches.

API ​

Props ​

PropDescriptionTypeDefault
model-value / v-modelBinding valuenumber—
minMinimum valuenumber-Infinity
maxMaximum valuenumberInfinity
stepStep sizenumber1
step-strictlyWhether to restrict input to multiples of stepbooleanfalse
precisionNumeric precisionnumber—
sizeSize'large' | 'default' | 'small''default'
disabledWhether to disablebooleanfalse
readonlyWhether to set read-onlybooleanfalse
controlsWhether to show control buttonsbooleantrue
controls-positionPosition of control buttons'' | 'right'''
prefixPrefix textstring—
suffixSuffix textstring—
prefix-iconPrefix iconComponent—
suffix-iconSuffix iconComponent—
clearableWhether it is clearablebooleanfalse
validatorCustom validation function(value: number | undefined) => boolean | string—
placeholderInput placeholderstring—
value-on-clearValue when clearednumber | null | 'min' | 'max'null
theme-overridesComponent-level theme overridesComponentThemeVarsundefined

Events ​

Event NameDescriptionCallback Parameters
changeTriggered when value changes(currentValue: number | undefined, oldValue: number | undefined) => void
inputTriggered on input(value: number | undefined) => void
focusTriggered on focus(event: FocusEvent) => void
blurTriggered on blur(event: FocusEvent) => void
clearTriggered on clear() => void

Slots ​

Slot NameDescription
prefixCustom prefix content
suffixCustom suffix content
decrease-iconCustom decrease button icon
increase-iconCustom increase button icon

Expose ​

NameDescriptionType
focusFocus the input() => void
blurBlur the input() => void
clearClear the value() => void

Theme Variables ​

YhInputNumber supports themeOverrides. The component itself consumes the following numeric-input CSS variables:

VariableDescriptionDefault
--yh-input-number-widthInput width150px
--yh-input-number-heightInput heightvar(--yh-component-size-default)
--yh-input-number-font-sizeFont sizevar(--yh-font-size-base)
--yh-input-number-bg-colorBackground colorvar(--yh-fill-color-blank)
--yh-input-number-border-colorBorder colorvar(--yh-border-color)
--yh-input-number-btn-colorButton colorvar(--yh-text-color-secondary)

Type Exports ​

NameDescription
YhInputNumberPropsProps type for YhInputNumber
YhInputNumberEmitsEmits type for YhInputNumber
YhInputNumberSlotsSlots type for YhInputNumber
YhInputNumberExposeExpose type for YhInputNumber
YhInputNumberSizeInput-number size union
YhInputNumberControlsPositionControls-position union
YhInputNumberInstancePublic instance type for YhInputNumber

Released under the MIT License.