Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

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

A cross-platform, smooth, lightweight, customizable PIN code input component for React Native.

License

NotificationsYou must be signed in to change notification settings

xamous/react-native-smooth-pincode-input

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A cross-platform, smooth, lightweight, customizable PIN code input component for React Native.

Most PIN code inputs components implemented by combining several TextInputs. They works, however, not good enough. When user types fast, or system sluggish, characters may lost when component switching focus between TextInputs. User need to type over and over again to get a correct input, gave a frustrated user experience.

React Native Smooth Pincode Input implemented with a different approach - It's based on single TextInput but only render it as seperated fields. In other words, it looks like a PIN code input, but works as smooth as a native TextInput.

React Native Smooth Pincode Input is also highly customizable. By exposing cells and text stylesheets, it can be fully customized to fit in your app design. Password mode also supported with customizable mask characters as well as placeholders.

Features

  • Smooth typing without losing inputs
  • Customizable cell style
  • Customizable text style
  • Password mode
  • Customizable password mask and placeholder characters
  • Built in animations (Credit toreact-native-animatable)

Installation

# yarnyarn add react-native-smooth-pincode-input# npmnpm i react-native-smooth-pincode-input

Examples

Default style with event handling

<SmoothPinCodeInputref={this.pinInput}value={code}onTextChange={code=>this.setState({ code})}onFulfill={this._checkCode}onBackspace={this._focusePrevInput}/>

Password with custom mask

<SmoothPinCodeInputpasswordmask="﹡"cellSize={36}codeLength={8}value={password}onTextChange={password=>this.setState({ password})}/>

Underline style

<SmoothPinCodeInputcellStyle={{borderBottomWidth:2,borderColor:'gray',}}cellStyleFocused={{borderColor:'black',}}value={code}onTextChange={code=>this.setState({ code})}/>

Customized style

<SmoothPinCodeInputplaceholder="⭑"cellStyle={{borderWidth:2,borderRadius:24,borderColor:'mediumturquoise',backgroundColor:'azure',}}cellStyleFocused={{borderColor:'lightseagreen',backgroundColor:'lightcyan',}}textStyle={{fontSize:24,color:'salmon'}}textStyleFocused={{color:'crimson'}}value={code}onTextChange={code=>this.setState({ code})}/>

Custom placeholder and mask using a component

<SmoothPinCodeInputplaceholder={<Viewstyle={{width:10,height:10,borderRadius:25,opacity:0.3,backgroundColor:'blue',}}></View>}mask={<Viewstyle={{width:10,height:10,borderRadius:25,backgroundColor:'blue',}}></View>}maskDelay={1000}password={true}cellStyle={null}cellStyleFocused={null}value={code}onTextChange={code=>this.setState({ code})}/>

Available props

NameTypeDefaultDescription
valueString''The value to show for the input
codeLengthNumber4Number of character for the input
cellSizeNumber48Size for each cell in input
cellSpacingNumber4Space between each cell
placeholderStringElement''
maskStringElement'*'
maskDelayNumber200The delay in milliseconds before a character is masked
passwordBooleanfalseMask the input value. Each cell masked withmask props
autoFocusBooleanfalseIf true, focuses the input oncomponentDidMount
editableBooleantrueIf false, makes each cell not editable
animatedBooleantrueToggle animations
animationFocusedString, Object'pulse'The animation of the focused cell. This can be a preset animation in the form of astring or acustom animation object.
restrictToNumbersBooleanfalseRestrict input to numbers only
containerStyleReact View StyleSheet{}View style for whole cell containers
cellStyleReact View StyleSheet{ borderColor: 'gray', borderWidth: 1}View style for each cell
cellStyleFocusedReact View StyleSheet{ borderColor: 'black', borderWidth: 2 }View style for focused cell
textStyleReact Text StyleSheet{ color: 'gray', fontSize: 24 }Text style for cell value
textStyleFocusedReact Text StyleSheet{ color: 'black' }Text style for focused cell value
onFulfillFunctionnullCallback function that's called when the input is completely filled
onTextChangeFunctionnullCallback function that's called when the text changed
onBackspaceFunctionnullCallback function that's called when the input is empty and the backspace button is pressed
keyboardTypeEnum('default', 'number-pad', 'decimal-pad', 'numeric', 'email-address', 'phone-pad')'numeric'Determines which keyboard to open

Thanks to contributors

About

A cross-platform, smooth, lightweight, customizable PIN code input component for React Native.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp