A one-time password / PIN input with individually-focusable boxes. Supports auto-advance on type, keyboard navigation, paste, and Angular Forms integration. Emits (completed) when all boxes are filled.
Default configuration with length="6" and numbersOnly="true".
Current value: —
Set [mask]="true" to hide the digits as password dots.
Run the following command to add this component to your project:
npx base-ui-cli add otp-input
For AI agents
Copy a prompt with the registry name, CLI install, and import — or add the Base UI MCP server.
npx -y base-ui-mcp
Base UI provides standalone components. Import the exact elements you want to use into your component.
// Install: npx base-ui-cli add otp-input
// Paths are relative to aliases.components (default: src/app/components)
import { OtpInputComponent } from './otp-input/otp-input.component';
@Component({
selector: 'app-your-component',
imports: [
OtpInputComponent
],
template: `...`
})
export class YourComponent {} API for otp-input — generated from JSDoc in the library source.
| API | Member | Type | Default | Description |
|---|---|---|---|---|
base-otp-input | class | string | '' | Additional host CSS classes (merged via cn()). |
base-otp-input | length | number | 6 | — |
base-otp-input | mask | boolean | false | — |
base-otp-input | numbersOnly | boolean | true | — |
base-otp-input | (completed) | string | — | Emitted when all boxes are filled with the full code string. |
base-otp-input | disabled | boolean | false | Whether the control is disabled (consumer-facing input). |
Content