Skip to content

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.

Current value: 1

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 size is 2

Step

Precision

Use the precision attribute to control numeric precision.

Precision set to 2 decimal places

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.

¥
%
$USD
Prefix and Suffix

Clearable

Use the clearable attribute to enable the clear button.

Shows clear button on hover

Clearable

Custom Validation

Use the validator attribute to define custom validation rules.

Validation range: 0 ~ 100

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

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

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)

Released under the MIT License.