# OTP Code Input

> Boxed one-time-code inputs for verification and two-factor screens.

- Category: [CSS Form Elements](https://copy-css.com/category/forms)
- Tags: otp, code, verification, pin, 2fa, input
- Live preview: https://copy-css.com/snippets/otp-input
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<div class="otp">
  <input type="text" inputmode="numeric" maxlength="1" value="4" aria-label="Digit 1">
  <input type="text" inputmode="numeric" maxlength="1" value="2" aria-label="Digit 2">
  <input type="text" inputmode="numeric" maxlength="1" aria-label="Digit 3">
  <input type="text" inputmode="numeric" maxlength="1" aria-label="Digit 4">
</div>
```

## CSS

```css
.otp {
  display: flex;
  gap: 10px;
}

.otp input {
  box-sizing: border-box;
  width: 46px;
  height: 56px;
  border: 1.5px solid #d1d5db;
  border-radius: 12px;
  background: #fff;
  color: #111;
  caret-color: #6366f1;
  font: 700 22px system-ui, sans-serif;
  text-align: center;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.otp input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}
```

## Notes

- This CSS OTP Code Input is 24 lines of pure CSS (0.5 KB) with no JavaScript and no dependencies. It uses transitions, box shadows and Flexbox.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
