# InputOTP

Native one-time code input with grouped visual slots and sanitized paste.

[All components](https://rickylabs.github.io/netscript/design-system/components/) · [Theme builder](https://rickylabs.github.io/netscript/create/) · [Implementation source](https://github.com/rickylabs/netscript/blob/main/packages/fresh-ui/registry/components/ui/input-otp.tsx)

## Live preview

[Open live input-otp preview](https://rickylabs.github.io/netscript/assets/fresh-ui/preview/?component=input-otp&theme=studio-utility)

## Install

```bash
netscript ui:add input-otp
```

## Usage and examples

The preview runs this JSX with the installed components. Import any composed primitives from your UI directory.

```tsx
import { useState } from 'preact/hooks';
import { InputOTP } from '@app/components/ui/input-otp.tsx';

export function Example() {
  const [value, setValue] = useState('standard');
  const [open, setOpen] = useState(false);
  const [notice, report] = useState('');
  return (<><div><InputOTP label="Verification code" /></div><p role="status">{notice}</p></>);
}
```

## Props

Generated from native `deno doc --json --private` over the shipped implementation. Compound component props retain their owning interface; native attributes pass through where declared.

| Owner | Prop | Type | Optional | Description |
| --- | --- | --- | --- | --- |
| `InputOTPProps` | `label` | `string` | No |  |
| `InputOTPProps` | `length` | `4 \| 6` | Yes |  |
| `InputOTPProps` | `groups` | `1 \| 2` | Yes |  |
| `InputOTPProps` | `value` | `string` | Yes |  |
| `InputOTPProps` | `defaultValue` | `string` | Yes |  |
| `InputOTPProps` | `onValueChange` | `(value: string) => void` | Yes |  |
| `InputOTPProps` | `state` | `"rest" \| "focus" \| "disabled" \| "invalid"` | Yes |  |
| `InputOTPProps` | `class` | `string` | Yes |  |

```typescript
InputOTPProps extends Omit<JSX.InputHTMLAttributes<HTMLInputElement>, "class" | "size" | "value" | "defaultValue" | "maxLength" | "children">
```

## Keyboard

| Key | Action |
| --- | --- |
| `ArrowLeft/ArrowRight/Home/End` | Move the native input selection |
| `Backspace/Delete` | Edit the native code input |
| `Paste` | Replace the native selection with sanitized digits |

## Tokens

Semantic contract roles: `border/input`, `destructive/default`, `radius/input`, `surface/card`, `text/fg`.

CSS custom properties referenced directly: `--ns-border-width`, `--ns-card`, `--ns-control-height`, `--ns-destructive`, `--ns-fg`, `--ns-input-border`, `--ns-muted-fg`, `--ns-radius-input`, `--ns-ring`, `--ns-space-3`, `--ns-space-4`, `--ns-text-strong`, `--ns-weight-strong`.

## Contract and compatibility

Accessibility pattern: native one-time-code input

- Native controls own keyboard/form behavior. Transient focus/hover is CSS/native; data-state also supports deliberate preview. Client visual/controlled updates require an island.
- One real text input handles selection, autofill and form value; grouped slots are aria-hidden mirrors. content is slot anatomy, not a caller prop. Paste normalizes ASCII digits and preserves native selection replacement.

Design contract values marked planned are not implementation props. The props above describe what ships today.
