Input · PinCode
PinCode
For easy and intuitive verification code entry
Code demonstration
How to import
PinCode supported from 2.62.0
Basic usage
Controlled
Use value to pass in the verification code string and use it with onChange for controlled use
Limit verification code format
Set the number of digits
Set the number of digits through count, the default is 6 digits, the demo below is set to 4 digits
Set character range
Use format to control the character range that can be entered
- Pass "number" to only allow numbers
- Pass "mixed" to allow numbers and letters
- Pass in a regular expression to only allow characters that can be judged by the regular expression
- Pass in a function, and the verification code will be passed in as parameters in units of characters for verification when entering. When the function returns true, the character is allowed to be entered into the PinCode
Manual focus and blur
Use the focus and blur methods on Ref, and the input parameter is the serial number of the corresponding Input
API Reference
| Property | Description | Type | Default value | Version |
|---|---|---|---|---|
| autoFocus | Whether to automatically focus on the first element | boolean | true | |
| aria-label, aria-labelledby, aria-describedby, aria-errormessage, aria-invalid, aria-required | Accessibility attributes passed to every input | Same as Input | ||
| className | Class name | string | ||
| count | Number of digits of verification code | number | 6 | |
| defaultValue | Default value of input box content | string | ||
| disabled | Disable | boolean | false | |
| id | ID of the first input, used to associate a label | string | ||
| format | Limitation of single character format of verification code | 'number'| 'mixed‘ | RegExp | (char:string)=>boolean | 'number' | |
| size | Input box size, large, default, small | string | 'default' | |
| style | Style | object | ||
| tabIndex | Tab index of every input | number | ||
| validateStatus | Validation status of every input | 'default'| 'error'| 'warning'| 'success' | ||
| value | Input box content | string | ||
| onChange | Input callback | (value:string)=>void | ||
| onComplete | Callback after all digits of verification code are entered | (value: string) => void |
Methods
Methods bound to component instances can be called through ref to implement certain special interactions
| Attributes | Description |
|---|---|
| focus | Focus, the input parameter is the verification code number |
| blur | Remove focus, the input parameter is the verification code number |