0.0.2 • Published 9 years ago

rn-number-input v0.0.2

Weekly downloads
20
License
MIT
Repository
github
Last release
9 years ago

rn-number-input

Created as an alternative to the native Picker component, rn-number-input is the number equivalent of <TextInput /> and behaves and looks very similar to what you see on the web <input type='number' />.

Screenshot of <NumberInput />

screenshot of the component

Installation

rn-number-input requires react-native 0.20 or later.

npm install --save rn-number-input

Example

To build the example locally, clone this repo then run:

cd example
npm install
react-native (run-ios|run-android)

Usage

import React from 'react-native';
import NumberInput from 'rn-number-input';

<NumberInput
	value={this.state.chickenWings}
	min={-10}
	max={10}
	onChange={(value) => this.setState({ chickenWings: value })}
	arrowColour='blue'
	width={70}
	height={40}
/>

Available Props

<NumberInput /> exposes all the props available to the <TextInput /> plus the following below:

PropertyTypeDefaultDescription
stepnumber1amount in which the value is increased or decreased
valuestring or number0value shown of the input
widthnumber70specifies the width of the component
heightnumber40specifies the height of the component
arrowColourstring#333 (dark grey)tintColor for the arrow icon
arrowStylestyledefault stylesspecifies the style for each arrow button
valueStylestyledefault stylesspecifies the style for value within the input
minnumber0specifies the min value
maxnumber100specifies the max value
decimalPointsnumber2how many decimal points that the value round's to
onChangefunc (required)undefinedfunction is called when the value is changed
editablebooleantruewhether the input can be edited directly using the keypad

Todo

  • Add Unit Tests

License

MIT Licensed Copyright (c) Cameron Bourke 2016