Skip to main content

Passcode -Password/Verification Code Component

Effect demonstration

1. Default effect

<Passcode clearTextOnFocus onChange={handleChange} keyboardType="phone-pad" ref={otpRef} selectTextOnFocus={false} />
default effect ios

2. Modify the number of digits in the verification code

<Passcode
clearTextOnFocus
onChange={handleChange}
keyboardType="phone-pad"
count={4}
ref={otpRef}
selectTextOnFocus={false}
/>
Modify verification code digits ios

3. Custom style

<Passcode
secureTextEntry={false}
ref={otpRef}
style={{ margin: 20 }}
inputContainerStyle={{ borderWidth: 1, borderColor: 'green' }}
focusStyle={{ borderWidth: 1, borderColor: 'red' }}
onFinish={() => console.log('222')}
/>
custom style ios

4. Password input style

<Passcode
secureTextEntry={true}
ref={otpRef}
style={{ margin: 20 }}
inputContainerStyle={{ borderWidth: 1, borderColor: 'green' }}
focusStyle={{ borderWidth: 1, borderColor: 'red' }}
onFinish={() => console.log('222')}
/>
manual setting page ios

API

Passcode (inherited from TextInputProps)

PropertiesRequiredDescriptionTypeDefault Value
keyboardTypefalsekeyboard typeKeyboardTypephone-pad
stylefalseContainer styleViewStyle
focusStylefalseThe style of a focused input boxViewStyle
valuefalseCurrently entered verification codestring
onChangefalseVerification code input callback(code: string) => void
inputContainerStylefalseInput box container styleViewStyle
inputStylefalseInput box styleTextStyle
countfalseVerification code lengthnumber6
onFinishfalseCallback after verification code input is completed() => void

PasswordInputRef

PropertiesDescriptionType
resetReset verification code() => void;
focusFocus verification code() => void;
getValueGet the currently entered verification code() => string;