2.0.0 • Published 3 years ago

vue-numeric-input v2.0.0

Weekly downloads
1,928
License
MIT
Repository
github
Last release
3 years ago

Vue Numeric Input

npm npm Build Status codecov npm

Number input component based on Vue that is a replacement of native input number with optional control.

vue-numeric-input

Live Demo & Doc

Installation

Install via NPM

$ npm install vue-numeric-input --save

Install via CDN

<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/vue-numeric-input"></script>

Global

Register VueNumericInput globally:

import Vue from 'Vue';
import VueNumericInput from 'vue-numeric-input';

Vue.use(VueNumericInput)

Local

Include the VueNumericInput directly into your component using import:

import VueNumericInput from 'vue-numeric-input'

export default {
  components: {
    VueNumericInput
  }
}

Usage

Basic usage

<template>
  <div>
    <vue-numeric-input  v-model="value" :min="1" :max="10" :step="2"></vue-numeric-input>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        value: 1,
      };
    },
  };
</script>

PROPS:

NameDescriptionTypeDefaultOptions
nameComponent nameString--
valueBinding valueNumber--
placeholderInput placeholderString--
minMinimum allowed valueNumber-Infinity-
maxMaximum allowed valueNumberInfinity-
stepIncremental StepNumber1-
alignAlignment of Numeric ValueStringleftleft, center, right
widthComponent WidthString150pxwidth in px, em, rem etc e.g. ‘20px’
sizeComponent SizeStringnormalsize value can be 'small', 'normal', 'large'
precisionNumber of decimalsNumber0Integer value
controlsEnable/Disable ControlsBooleantruetrue/false
controlsTypeControls TypeStringplusminusplusminus/updown
autofocusAutofocus on Page LoadBooleanfalsetrue/false
readonlyIs ReadonlyBooleanfalsetrue/false
disabledIs DisabledBooleanfalsetrue/false
isinputenable/disable keyboard input of numberBooleanfalsetrue/false
mousewheelEnable increment/decrement with mousewheel eventBooleanfalsetrue/false
classNameCss Class for Input ComponentString-css class name

EVENTS:

Event NameDescriptionParameters
inputtriggers when input(newValue)
changetriggers when the value changes(newValue)
blurtriggers when Input blurs(event: Event)
focustriggers when Input focus(event: Event)

METHODS:

MethodDescriptionParameters
focusfocus the Input component-
blurblur the Input component-

Inspired by react-numeric-input

License

MIT