# nitro-otp

> One Time Password (OTP) / PIN Input Angular Library Component for the web

Latest version **1.1.0-ng17** (published 2024-02-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install nitro-otp
pnpm add nitro-otp
yarn add nitro-otp
bun add nitro-otp
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0-ng17 |
| Published | 2024-02-12 |
| First published | 2020-09-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 51.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Ajith S Punalur |
| Maintainers | asphub |
| Keywords | otp, pin, input, nitro, angular, ng-nitro, nitro-otp, otp-input, pin-input, typescript, @ng-nitro, component, library, plugin, ng, 16 |

## Links

- npm: https://www.npmjs.com/package/nitro-otp
- Repository: https://github.com/asphub/nitro-ng-components
- Homepage: https://github.com/asphub/nitro-ng-components/#nitro-otp
- Issues: https://github.com/asphub/nitro-ng-components/issues
- npm.io page: https://npm.io/package/nitro-otp

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.5.0

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [btrz-health-check](https://npm.io/package/btrz-health-check.md) — 474 weekly downloads

## Recent versions

- 1.1.0-ng17 (latest) — 2024-02-12
- 1.0.16-ng17 — 2024-02-12
- 1.0.16 — 2024-02-09
- 1.0.15 — 2023-03-05
- 1.0.14 — 2023-03-04
- 1.0.13 — 2023-03-03
- 0.5.0 — 2021-05-18
- 0.4.0 — 2020-11-15
- 0.2.0 — 2020-09-26
- 0.1.0 — 2020-09-26
- 0.0.1 — 2020-09-25

## README

# @nitro/otp (OTP / PIN Input)

[![Angular Library - Nitro OTP](https://img.shields.io/static/v1?label=npm+package&message=1.1.0-ng17&color=green?style=for-the-badge&logo=npm)
](https://www.npmjs.com/package/nitro-otp)

[![Angular Library - Nitro OTP](https://img.shields.io/static/v1?label=Angular&message=17.1.3&color=green?style=for-the-badge&logo=angular)
](https://www.npmjs.com/package/nitro-otp)

One Time Password (OTP) Input Angular Library Component for the web built with Angular `17.1.3` and tested from all versions `>= 10.0.0`.

This can be used as OTP inputs or Personal Identification Number (PIN) inputs or for all each character specific inputs.

> _If you are facing any issues with lower versions of angular, Please use the previous versions._

## Features:

1. *Light weight*
2. *Fully customizable*
3. *CSS vars for theming*
4. *In-Built Boxed & Dashed appearance*

## Usage

`app.module.ts`
```ts
import { OtpModule } from 'nitro-otp';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    OtpModule
  ]
})
```

`some.component.ts`
```ts
import { OtpComponent } from 'nitro-otp';
```

`some.component.html`
```html
<nitro-otp #otp [size]="4" message="Incorrect OTP" [autoFocus]="true" (otpChange)="afterOtpChanged($event)"></nitro-otp>
```

#### Error Management Example:
`some.component.ts`
```ts
// Below code are OPTIONAL for error display
export class SomeComponent {
  @ViewChild('otp')
  private otp!: OtpComponent;

  afterOtpChanged(otpVal: [string, boolean]): void {
    const [value, length] = otpVal;
    // value: Value of OTP Input
    // length: TRUE, if length matches and vice-versa
    
    // Write your validation code here `this.otp.isError.next(true);` will set Error
    this.otp.isError.next(!length);
  }
}
```

## API:
|Name|Type|Default|Description|
|---|---|---|---|
|`appearance`|`String`| `legacy` | <details><summary>*Change Appearance of Control*</summary>Change appearance of OTP input (legacy / dashed)<br><br>__Eg.:__<br>`<nitro-otp [appearance]="dashed"></nitro-otp>`<br><br>__Accepted Values:__<br>`legacy` / `dashed` / `<any_string>`<br><br><blockquote>Custom String will be added as a class prefixed by an underscores (like `_customTheme`)</blockquote></details>|
|`autoFocus`|`Boolean`| `true` | <details><summary>*Autofocus to Input*</summary>Toggle autoFocus to OTP input<br>__Eg.:__<br>`<nitro-otp [autoFocus]="true"></nitro-otp>`</details>|
|`message`|`String`| `""` | <details><summary>*Message to show*</summary>Custom message to show when an Error occurs<br>__Eg.:__<br>`<nitro-otp [message]="'Invalid OTP'"></nitro-otp>`</details>|
|`passwordChar`|`String`| `•` | <details><summary>*passwordChar to show*</summary>Custom Character to mask the OTP<br>__Eg.:__<br>`<nitro-otp [passwordChar]="*"></nitro-otp>`</details>|
|`revealChar`|`Boolean`| `true` | <details><summary>*Set the Characters Reveal or Not*</summary>Set Character to mask or show for OTP<br>__Eg.:__<br>`<nitro-otp [revealChar]="true"></nitro-otp>`</details>|
|`size`|`Number`| `4` | <details><summary>*Max. Size of Input*</summary>Defines the maximum size of OTP / Pin Input Control<br>__Eg.:__<br>`<nitro-otp [size]="4"></nitro-otp>`</details>|

**CSS Variables:**
```css
:root {
  --nitro-otp_border-color: goldenrod;
  --nitro-otp_border-color_focus: blue;
  --nitro-otp_border-color_error: red;
}
```

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version `17.1.3`.

---
_Source: https://npm.io/package/nitro-otp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
