1.0.6 • Published 4 years ago

react-analog-number-input v1.0.6

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

react-analog-number-input

A react component that displays number inputs as analog.

Demo and Example

Live Demo: https://blakdave.github.io/react-analog-number-input/

Installation

Use the package manager npm to install react-analog-number-input.

npm install react-analog-number-input

Import as follows:

import ReactAnalogNumberInput from 'react-analog-number-input'

// CSS
import 'react-analog-number-input/css/react-analog-number-input.css';

Usage

The default layout is vertical.

const onChange = value => {
    // use value in function
};

<ReactAnalogNumberInput onChange={onChange} />

Horizontal Layout

const onChange = value => {
    // use value in function
};

<ReactAnalogNumberInput onChange={onChange} horizontal />

Custom Icons

You can customize the icons to use your images

const addIcon = <img src="your-image-link-here" />
const subtractIcon = <img src="your-image-link-here" />

const onChange = value => {
    // use value in function
};

<ReactAnalogNumberInput onChange={onChange} addIcon={addIcon} subtractIcon={subtractIcon} />

Available Props

PropDescriptionTypeValue
onChangeThis is the function that receives the component's value on your endFunction
valueThe default valueOptionalNumberDefault is 0
maxMaximum valueOptionalNumberDefault is 20
classNameCustom css class to help you style the component betterOptionalString
horizontalThe layout of the componentOptionalBooleanDefault is false
addIconCustom "add" icon for the vertical layout. e.g <img src="your-img-link-here" />OptionalHTML ELement
subtractIconCustom "subtract" icon for the vertical layout. e.g <img src="your-img-link-here" />OptionalHTML ELement
horizontalAddIconCustom "add" icon for the horizontal layout. e.g <img src="your-img-link-here" />OptionalHTML ELement
horizontalSubtractIconCustom "subtract" icon for the horizontal layout. e.g <img src="your-img-link-here" />OptionalHTML ELement

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT Copyright (c) David (Blak Dave) 2020.