1.0.2 • Published 3 years ago

react-bootstrap-input-spinner v1.0.2

Weekly downloads
9
License
GPL-3.0-or-later
Repository
github
Last release
3 years ago

react-bootstrap-input-spinner

An input number spinner based on Bootstrap for React.

Set min and max values, use increase and decrease buttons, type value directly into the input, and set Bootstrap element properties.

This project is based on React Native Input Spinner by Marco Cesarato. Click here to check out his Github.

Install

$ npm install react-bootstrap-input-spinner

Usage

import InputSpinner from 'react-bootstrap-input-spinner'  
  
<InputSpinner
    type={'real'}
    precision={2}
    max={1.2}
    min={0}
    step={0.01}
    value={value}
    onChange={num=>console.log(num)}
    variant={'dark'}
    size="sm"
/>

Run example

Make sure you have a recent version of Node.js installed in your development environment.

Cloning Repository

$ git clone https://github.com/rodrigues-t/react-bootstrap-input-spinner.git

Installing all dependencies (library and playground)

$ cd react-bootstrap-input-spinner && npm run i-all

Runinng for test

$ npm run dev

Props List

PropertyDescriptiontypeDefault
arrowsOptional Set if labels on right and left buttons will be < and > instead of - and +booleanfalse
disabledOptional Set if component is disabledbooleanfalse
editableOptional Set if input number field is editablebooleantrue
maxmaximum value permittednumberNumber.MAX_SAFE_INTEGER
minminimum value permittednumber0
precisionMaximum numbers after commanumber
sizeOptional Bootstrap element size. sm or lganyundefined
stepValue to increment or decrement the spinner valuenumber
typeType of the spinner. int or real/float/double/decimalstring
valueValue of the spinnernumber
variantOptional React Bootstrap variantsstringprimary

Handlers

HandlerDescription
onChangeCallback called when value changes(num: number)=>void
onMaxOptional Callback called when max value is reached(num: number)=>void
onMinOptional Callback called when min value is reached(num: number)=>void
onIncreaseOptional Callback called when increase button is hitted(num: number)=>void
onDecreaseOptional Callback called when decrease button is hitted(num: number)=>void

Contribute

If you want to contribute to this project, please read this.