
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
ngx-otp-code-input
Advanced tools
ngx-otp-code-input is an Angular component for OTP (One-Time Password) input. This component is highly customizable, allowing for various configurations such as masking, integer-only input, autofocus, and more.
ngx-otp-code-input is an Angular component for OTP (One-Time Password) input. This component is highly customizable, allowing for various configurations such as masking, integer-only input, autofocus, and more.
If you like the library, please consider giving it a ⭐ on GitHub.
Install the package via npm:
npm install ngx-otp-code-input
Add NgxOtpCodeInputModule to your Angular module:
import { NgxOtpCodeInputModule } from 'ngx-otp-code-input';
@NgModule({
declarations: [
// your components
],
imports: [
// other modules
NgxOtpCodeInputModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Add the ngx-otp-code-input component to your template:
<ngx-otp-code-input
[length]="6"
[mask]="false"
[integerOnly]="false"
[disabled]="false"
variant="outline"
[readonly]="false"
[autofocus]="true"
[animationConfig]="{ type: 'slide', duration: '1.0s' }" <!-- Optional: Configure animations -->
[status]="otpStatus" <!-- Bind this to a variable in your component -->
[successIcon]="'check_circle'" <!-- Optional: Bind to a custom icon for success -->
[failureIcon]="'cancel'" <!-- Optional: Bind to a custom icon for failure -->
[tabIndex]="true"
(otpChange)="onOtpChange($event)"
(otpComplete)="onOtpComplete($event)"
></ngx-otp-code-input>
Add event handlers in your component:
export class AppComponent {
otpStatus: 'success' | 'failed' | null = null;
onOtpComplete(event: string): void {
console.log('OTP Complete:', event);
}
onOtpChange(event: string): void {
console.log('OTP Change:', event);
}
}
Input | Type | Default | Description |
---|---|---|---|
length | number | 4 | Number of OTP input fields. |
mask | boolean | false | Hide the input values (like a password field). |
integerOnly | boolean | false | Restrict input to only integer values. |
disabled | boolean | false | Disable the input fields. |
readonly | boolean | false | Make the input fields read-only. |
autofocus | boolean | true | Automatically focus on the first input field. |
tabIndex | boolean | false | Enable tab navigation between input fields. |
inputClass | string | '' | Custom CSS class for the input fields. |
variant | MatFormFieldAppearance | 'outline', 'fill' | Appearance of the Material form field. |
regex | string | '' | Custom regex pattern for the input fields. |
status | any | null | Visual status of OTP verification. |
successIcon | string | 'check_circle' | Custom icon for success status. |
failureIcon | string | 'error' | Custom icon for failure status. |
animationConfig | { type: string, duration: string } | { type: 'slide', duration: '1.0s' } | Configuration for animations when focusing between input fields. |
Output | Type | Description |
---|---|---|
otpChange | EventEmitter<string> | Emits the current OTP value when it changes |
otpComplete | EventEmitter<string> | Emits the OTP value when all fields are filled. |
Contributions are welcome! Please submit a pull request or open an issue to discuss changes. 🚀
FAQs
ngx-otp-code-input is an Angular component for OTP (One-Time Password) input. This component is highly customizable, allowing for various configurations such as masking, integer-only input, autofocus, and more.
The npm package ngx-otp-code-input receives a total of 1 weekly downloads. As such, ngx-otp-code-input popularity was classified as not popular.
We found that ngx-otp-code-input demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.