Skip to content

OtpInput

EOtpInput (a one-time password) is a number or alphanumeric string of characters produced automatically to authenticate a user for a single transaction or login. Demo Here

Import

jsx
import EOtpInput from "@components/Form/EOtpInput";

Usage

jsx
const OtpInputExample = () => {
    const [value, setValue] = useState("");

    const changeHandler = (newValue) => {
        setValue(newValue);
    };

    return (
        <EOtpInput
            label="Enter the code"
            onChange={changeHandler}
            value={value}
        />
    )
};

export default OtpInputExample;

Props

For EOtpInput component, the following props are available:

PropTypeDefaultNote
valueString-The value of the otp input element.
labelnode-Component's label
idString-HTML id attribute.
disabledBooleanfalseDisables the EOtpInput.
variantString"fill"The EOtpInput element can be represented in four ways: fill and border.
width[String, Number]-Sets the component's width. Default unit is px.ght.
height[String, Number]-Sets the component's height. Default unit is px.
squareBooleanfalseSquares the corners of the OTP.
messageString-Adds a message below the input.
digitsLengthNumber6Specify the length of the OTP Input.
pasteBooleanfalseEnables the user to paste one output to multiple OTP.
classNameString-Overrides or extends the component's styles.
nameString-HTML name attribute..
validateOnString"input"Triggers validation on @values: submit, input, blur.
rulesArray-Validation rules. For more info refer to Form Validation.
stateString-Validates the user-provided data against established criteria and performs display validation. States can be none if no validation is necessary, danger if the selected is valid, or success if it is acceptable.
readOnlyBooleanfalseSame as readonly in native OTP makes the element not mutable.
sizeString"md"The EOtpInput element has three predefined sizes: sm, md, lg.
alignString"start"Specifies how the pagination buttons are distributed along the cross axis in a container.
colorString"primary"The given color is applied to the element - utility colors are supported (e.g primary or danger). you'll find a list of built-in classes on the src/styles/_vars.scsspage.

Callback Functions

The EInput component contains following callback functions.

FunctionDescription
onChangeControls the input. function(event: React.SyntheticEvent, value: String) => void 👇

event: The event source of the callback.
value: input value.

COPYRIGHT