- API
- Base props
- Style props
CellComponent?: ComponentType
maskSymbol?: string
keyboardType?: KeyboardType
activeColor?: string
inactiveColor?: string
cellBorderWidth?: number
space?: number
size?: number
inputPosition?: 'left' | 'right' | 'center' | 'full-width'
variant?: 'border-box' | 'border-circle' | 'border-b' | 'clear'
blurOnSubmit?: boolean
- Customize props
- Other props
- Functions
Callback function called when fulfilling code.
Required
This function will called before setState will apply a new code. It useful when you need check pasted user text.
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
Control the focus after submitting. Default true
A react component that use for render cell. It is really helpful for create animation.
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
: unique 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}
// ...
/>
);
}
}