Callback function called when fulfilling code.
Required
Auto focus on code input, Default false
Length of confirmation code -> number of cells. Default 5
Default code value, must be the same length as codeLength
A symbol that will be displayed when the field is filled. Supports emoji.
Determines which keyboard to open.
Default value: "number-pad"
Color of cells when active. Default #fff
. Demo activeColor
:
Color of cells when inactive. Default #ffffff35
. Demo inactiveColor
:
Width of cell borders. Default 1
. Demo cellBorderWidth
:
Space between 2 cells. Default 8
. Demo space
:
Size of input cells. Default 40
. Demo size
:
The position of code input in its container. Default center
. Demo inputPosition
:
Some built-in variants. Default border-box
. Demo variant
:
cellProps: TextInputProps | ({index: number, isFocused: boolean, hasValue: boolean}) => ?TextInputProps
That property help customize Cells. When pass Object it must be <TextInput/>
component props and this object will spread for each cell.
And if you pass function component will call with next options:
index
: uniq number of cellisFocused
: is cell in focus nowhasValue
: is cell has value
Your function must will pass TextInputProps or null.
(Example for custom style)
Help in test
Method that will focus the TextInput programmatically.
Method that will blur the TextInput programmatically.
Method to clear the entered code.
import React, { Component, createRef } from 'react';
import CodeInput from 'react-native-confirmation-code-field';
class App extends Component {
inputRef = createRef();
handlerOnIvalidCode() {
const { current } = this.inputRef;
if (current) {
current.clear();
}
}
render() {
return (
<CodeInput
ref={this.inputRef}
// ...
/>
);
}
}