1.0.8 • Published 5 years ago

react-input-number-editor v1.0.8

Weekly downloads
2
License
MIT
Repository
gitlab
Last release
5 years ago

react-input-number-editor

React component that act like adobe suite editor number input field that can be slided.

Gitlab pipeline status (branch) coverage report npm

Demo

Preview Image

Live demo available here

Features

  • Mouse lock on drag
  • Custom number decimal precision
  • Manual editing of the input
  • Editing cancellation
  • Increment/decrement the value with arrow up and arrow down key
  • Use ctrl and shift key to increment/decrement the value with higher/lesser step
  • Change the value from external event
  • Customize the step modifier for ctrl and shift key
  • Customize the slide modifier for dragging accuracy

Install

$ npm install --save react-input-number-editor

Or

$ yarn add react-input-number-editor

Example

import React, { useState } from 'react';

import InputNumberEditor from 'react-input-number-editor';

function Example() {
    const [value, setValue] = useState(0);

    function handleChange(value) {
        setValue(value);
    }

    return (
        <InputNumberEditor
            value={value}
            min={0}
            max={100}
            precision={1}
            onChange={handleChange}
        />
    );
}

Usage

PropDescriptionTypeDefaultRequired
valueThe value to set the input tonumber0Yes
minThe minimum value reachablenumber-No
maxThe maximum value reachablenumber-No
precisionNumber of decimalsnumber0No
stepNumber of the steppingnumber1No
stepModifierModifier for the stepping (Ctrl and Shift key)number10No
slideModifierModifier for the sliding/dragging modestring0.3No
onChangeCallback called on value changefunc() => ()No

License

MIT © Vinarnt