Socket
Socket
Sign inDemoInstall

react-native-input-spinner

Package Overview
Dependencies
1
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-native-input-spinner

React native input with increase and decrease buttons


Version published
Weekly downloads
1.2K
decreased by-1.95%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

If this project has helped you out, please support us with a star 🌟


NPM version Package Quality js-prittier-style Compatibility

📘 Description

Author: Marco Cesarato

Github: https://github.com/marcocesarato/react-native-input-spinner

An extendible input number spinner component for react-native highly customizable. This component enhance a text input for entering numeric values, with increase and decrease buttons.

Try it on the published demo web app: https://marcocesarato.github.io/react-native-input-spinner/

Compatible with: Android, iOS, Windows, Web and Expo.

📖 Install

Install the library from npm or yarn just running one of the following command lines:

npmyarn
npm install react-native-input-spinner --saveyarn add react-native-input-spinner

NPM

💻 Usage

import InputSpinner from "react-native-input-spinner";

// Example
<InputSpinner
	max={10}
	min={2}
	step={2}
	colorMax={"#f04048"}
	colorMin={"#40c5f4"}
	value={this.state.number}
	onChange={(num) => {
		console.log(num);
	}}
/>;

For more examples check the Example directory the App.js file

🎨 Screenshots

Default props + Min & Max colorsNot rounded, showBorder, Min & Max colors

High customization

SkinsCustomization

⚡️ Example

Web

https://marcocesarato.github.io/react-native-input-spinner/

Expo

Clone or download repo and after:

cd Example
yarn install # or npm install
expo start

Open Expo Client on your device. Use it to scan the QR code printed by expo start. You may have to wait a minute while your project bundles and loads for the first time.

Example App Screenshot

💡 Props

Check the "Props List" file to have the complete list of component props ordered by name.

Structure

Handlers

HandlerDescriptionFunc
onBlurCallback that is called when the text input is blurred.(e) => { ... }
onChangeCallback that is called when the number of the Spinner change.(num) => { ... }
onDecreaseCallback that is called when decrease button is clicked get value decreased.(decreased) => { ... }
onFocusCallback that is called when the text input is focused.(e) => { ... }
onIncreaseCallback that is called when increase button is clicked get value increased .(increased) => { ... }
onKeyPressCallback that is called when a key is pressed.(e) => { ... }
onLongPressCallback that is called when holding the right or the left buttonFunction
onMaxCallback that is called when max is reached get max number permitted.(max) => { ... }
onMinCallback that is called when min is reached get min number permitted.(min) => { ... }
onSubmitEditingCallback that is called when the text input's submit button is pressed(e) => { ... }

Props

PropertyDescriptionTypeDefaultNote
accelerationDelayDelay time before start the onLongPress event and increase or decrease and continuallyNumber1000
appendCustom element before right buttonComponent
autoFocusIf true, focuses the input on componentDidMount.false
continuityOn min value is reached next decrease value will be the max value, if max is reached next increase value will be the min valueBooleanfalse
disabledDisable the Spinner or notBooleanfalse
editableSet if input number field is editable or notBooleantrue
emptiedSet if input can be emptyBooleanfalse
initialValueInitial value of the SpinnerString
Number
0
inputPropsCustomized TextInput Component propsObjectnullCould overwrite other props
leftButtonPropsCustomized left button (Touchable Component) propsObjectnullCould overwrite other props
maxLengthLimits the maximum number of characters that can be entered.Number
maxMax number permittedString
Number
null
minMin value permittedString
Number
0
placeholderThe string that will be rendered when text input value is equal to zeroStringnull
placeholderTextColorThe text color of the placeholder string.Stringnull
precisionMax numbers permitted after commaInteger2
prependCustom element after left buttonComponent
returnKeyLabelSets the return key to the label. Use it instead of returnKeyType.String
returnKeyTypeDetermines how the return key should look. On Android you can also use returnKeyLabelString
rightButtonPropsCustomized right button (Touchable Component) propsObjectnullCould overwrite other props
selectTextOnFocusIf true, all text will automatically be selected on focus.Boolfalse
selectionColorThe highlight and cursor color of the text input.Stringnull
stepValue to increment or decrement the current spinner valueString
Number
1
longStepValue to increment or decrement the current spinner value onLongPressString
Number
step
speedSpeed acceleration ratio of increase or decrease onLongPressNumber7(value from 1 to 10)
buttonTextPropsCustomized text button propsObjectnull
typingTimeTime before debounce and trigger onChange eventNumber750
typeType of spinnerStringintCan be int or real/float...
valueControlled value of the SpinnerString
Number
0
formatterAn optional function that is called to format the value for displayFunctionnullShould return a string. editable must be false.
Screenshots
Description
  • Top spinner with a child
  • Bottom spinner with prepend and append

Props Styles

PropertyDescriptionTypeDefaultNote
buttonPressStyleButton style on Pressed stateObjectCould overwrite other props
buttonStyleButton styleObjectCould overwrite other props
inputStyleText Input styleObjectCould overwrite other props
skinSkin layoutStringclean, modern, paper, round, square
styleContainer styleObjectCould overwrite other props

Props Colors

PropertyDescriptionTypeDefaultNote
backgroundCustom input text background colorStringtransparent
buttonPressTextColorCustom color of the button of the Spinner on Pressed stateStringAuto
buttonTextColorCustom color of the label's button of the SpinnerStringAuto
colorAsBackgroundUse color as backgroundBoolfalse
colorLeftCustom color of the Spinner left buttonString#3E525F
colorMaxCustom color of the Spinner when reach max valueString
colorMinCustom color of the Spinner when reach min valueString
colorPressCustom color of the Spinner button on touch pressString#3E525F
colorRightCustom color of the Spinner right buttonString#3E525F
colorCustom color of the SpinnerString#3E525F
textColorCustom input text number colorStringAuto
Screenshots
Description
  • Spinner with color, buttonTextColor, colorPress and buttonPressTextColor custom colors

Props Container Style

PropertyDescriptionTypeDefaultNote
heightCustom height of the SpinnerNumber50
shadowShow container shadowBooleanfalseUse with background like background={"#FFF"}
showBorderShow the border of the Spinner or notBooleanfalseUse with rounded={false}
styleContainer styleObjectCould overwrite other props
widthCustom width of the SpinnerNumber150

Props Buttons Style

PropertyDescriptionTypeDefaultNote
activeOpacityOpacity of underlay on pressed buttonNumber0.85
arrowsLabels on button will be (< and >) instead of (+ and -)Booleanfalse
buttonFontFamilyCustom fontFamily of buttons of the SpinnerStringSystem Default
buttonFontSizeCustom fontSize of buttons of the SpinnerNumber14
buttonLeftDisabledDisable left buttonBooleanfalse
buttonLeftImageCustom element on the button left of the spinnerComponentCould overwrite other props
buttonLeftTextCustom text on the button left of the spinnerString
buttonPressLeftImageCustom element on the button left of the spinner on pressed stateComponentCould overwrite other props
buttonPressRightImageCustom element on the button right of the spinner on pressed stateComponentCould overwrite other props
buttonPressStyleButton Style on Pressed state (Plus and Minus buttons)Object
buttonPressTextColorCustom color of the button of the Spinner on Pressed stateString#FFFFFF
buttonRightDisabledDisable right buttonBooleanfalse
buttonRightImageCustom element on the button right of the spinnerComponentCould overwrite other props
buttonRightTextCustom text on the button right of the spinnerString
buttonStyleButton Style (Plus and Minus buttons)Object
buttonTextColorCustom color of the labels's button of the SpinnerString#FFFFFF
buttonPressTextStyleButton Style on Pressed state (Plus and Minus buttons)ObjectCould overwrite other props
buttonTextStyleButton text Style state (Plus and Minus buttons)ObjectCould overwrite other props
roundedUse circular buttonBooleantrue

Props Text Input Style

PropertyDescriptionTypeDefaultNote
backgroundCustom input text background colorStringtransparent
fontFamilyCustom fontFamily of the text input of the SpinnerStringSystem Default
fontSizeCustom fontSize of the text input of the SpinnerNumber14
inputStyleText Input styleObjectCan overwrite other props
textColorCustom input text number colorString#000000

🤔 How to contribute

Have an idea? Found a bug? Please raise to ISSUES. Contributions are welcome and are greatly appreciated! Every little bit helps, and credit will always be given.


Keywords

FAQs

Last updated on 25 Apr 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc