Contents
- Outline mode
- Filled mode
- Underline mode
Having trouble getting help?
Contact Support
Contact Support
Styling Modes in EJ2 JavaScript OTP Input control
18 Jul 20247 minutes to read
Styling modes specify the style variants for the input fields in the OTP Input component. These modes allows you to customize the appearance of the OTP input fields.
Outline mode
You can use the outline style by setting the stylingMode property to outlined. The default styling mode is outlined
.
// Initializes the OTP Input control
var otpInput = new ej.inputs.OtpInput({
stylingMode: "outlined"
});
// Render initialized OTP Input.
otpInput.appendTo('#otp_outlined');
<!DOCTYPE html>
<html lang="en">
<head>
<title>Essential JS 2 - OTP Input</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="description" content="Essential JS 2">
<meta name="author" content="Syncfusion">
<link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-base/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-inputs/styles/material.css" rel="stylesheet" />
<!--style reference from app-->
<link href="index.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/29.1.33/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='container' style="width: 350px;">
<div id="otp_outlined"></div>
</div>
<script>
var ele = document.getElementById('container');
if (ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body>
</html>
#container {
visibility: hidden;
margin: 50px auto;
width: 350px;
}
#loader {
color: #008cff;
height: 40px;
left: 45%;
position: absolute;
top: 45%;
width: 30%;
}
Filled mode
You can use the filled style by setting the stylingMode property to filled.
// Initializes the OTP Input control
var otpInput = new ej.inputs.OtpInput({
stylingMode: "filled"
});
// Render initialized OTP Input.
otpInput.appendTo('#otp_filled');
<!DOCTYPE html>
<html lang="en">
<head>
<title>Essential JS 2 - OTP Input</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="description" content="Essential JS 2">
<meta name="author" content="Syncfusion">
<link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-base/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-inputs/styles/material.css" rel="stylesheet" />
<!--style reference from app-->
<link href="index.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/29.1.33/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='container' style="width: 350px;">
<div id="otp_filled"></div>
</div>
<script>
var ele = document.getElementById('container');
if (ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body>
</html>
#container {
visibility: hidden;
margin: 50px auto;
width: 350px;
}
#loader {
color: #008cff;
height: 40px;
left: 45%;
position: absolute;
top: 45%;
width: 30%;
}
Underline mode
You can use the underline style by setting the stylingMode property to underlined.
// Initializes the OTP Input control
var otpInput = new ej.inputs.OtpInput({
stylingMode: "underlined"
});
// Render initialized OTP Input.
otpInput.appendTo('#otp_underlined');
<!DOCTYPE html>
<html lang="en">
<head>
<title>Essential JS 2 - OTP Input</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<meta name="description" content="Essential JS 2">
<meta name="author" content="Syncfusion">
<link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-base/styles/material.css" rel="stylesheet" />
<link href="https://cdn.syncfusion.com/ej2/29.1.33/ej2-inputs/styles/material.css" rel="stylesheet" />
<!--style reference from app-->
<link href="index.css" rel="stylesheet">
<script src="https://cdn.syncfusion.com/ej2/29.1.33/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id='container' style="width: 350px;">
<div id="otp_underlined"></div>
</div>
<script>
var ele = document.getElementById('container');
if (ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body>
</html>
#container {
visibility: hidden;
margin: 50px auto;
width: 350px;
}
#loader {
color: #008cff;
height: 40px;
left: 45%;
position: absolute;
top: 45%;
width: 30%;
}