Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

License

NotificationsYou must be signed in to change notification settings

marcocesarato/react-native-input-spinner

Repository files navigation

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


NPM versionPackage Qualityjs-prittier-styleCompatibility

📘 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

importInputSpinnerfrom"react-native-input-spinner";// Example<InputSpinnermax={10}min={2}step={2}colorMax={"#f04048"}colorMin={"#40c5f4"}value={this.state.number}onChange={(num)=>{console.log(num);}}/>;

For more examples check theExample directory theApp.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 Exampleyarn install# or npm installexpo start

Open Expo Client on your device. Use it to scan the QR code printed byexpo 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 theonLongPress event and increase or decrease and continuallyNumber1000
appendCustom element before right buttonComponent
autoFocusIftrue, focuses the input oncomponentDidMount.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 ofreturnKeyType.String
returnKeyTypeDetermines how the return key should look. On Android you can also usereturnKeyLabelString
rightButtonPropsCustomized right button (Touchable Component) propsObjectnullCould overwrite other props
selectTextOnFocusIftrue, 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 valueonLongPressString
Number
step
speedSpeed acceleration ratio of increase or decreaseonLongPressNumber7(value from1 to10)
buttonTextPropsCustomized text button propsObjectnull
typingTimeTime before debounce and triggeronChange eventNumber750
typeType of spinnerStringintCan beint orreal/float...
valueControlled value of the SpinnerString
Number
0
formatterAn optional function that is called to format the value for displayFunctionnullShould return astring.editable must befalse.

Screenshots

Description
  • Top spinner with a child
  • Bottom spinner withprepend andappend

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 withcolor,buttonTextColor,colorPress andbuttonPressTextColor custom colors

Props Container Style

PropertyDescriptionTypeDefaultNote
heightCustom height of the SpinnerNumber50
shadowShow container shadowBooleanfalseUse withbackground likebackground={"#FFF"}
showBorderShow the border of the Spinner or notBooleanfalseUse withrounded={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 toISSUES.Contributions are welcome and are greatly appreciated! Every little bit helps, and credit will always be given.


About

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

Topics

Resources

License

Stars

Watchers

Forks

Contributors15


[8]ページ先頭

©2009-2025 Movatter.jp