# createOtp API

> Auto-generated API reference for `createOtp` from @vuetify/v0 (Vuetify0).
> Source of truth: https://0.vuetifyjs.com/api/create-otp

## Related

- https://0.vuetifyjs.com/composables/forms/create-otp
- https://0.vuetifyjs.com/composables/forms/create-input
- https://0.vuetifyjs.com/composables/forms/create-validation

## Functions

### createOtp

```ts
(_options?: OtpOptions) => OtpContext
```

## Options

| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| `id` | `ID \| undefined` | — | no | Unique identifier (auto-generated if omitted). |
| `label` | `string \| undefined` | — | no | Display label. |
| `name` | `string \| undefined` | — | no | Form field name. |
| `form` | `string \| undefined` | — | no | Associate with form by ID. |
| `required` | `boolean \| undefined` | — | no | Whether required. |
| `disabled` | `MaybeRefOrGetter<boolean> \| undefined` | — | no | Disabled state. |
| `readonly` | `MaybeRefOrGetter<boolean> \| undefined` | — | no | Readonly state. |
| `rules` | `(string \| FormValidationRule \| StandardSchemaV1)[] \| undefined` | — | no | Validation rules. |
| `dirty` | `((value: T) => boolean) \| undefined` | — | no | Predicate for "has content". |
| `equals` | `((a: T, b: T) => boolean) \| undefined` | `===` | no | Equality check for pristine tracking. |
| `length` | `MaybeRefOrGetter<number> \| undefined` | `6` | no | Number of characters. |
| `value` | `Ref<string, string> \| undefined` | `shallowRef('')` | no | Joined value source. |
| `pattern` | `MaybeRefOrGetter<OtpPattern> \| undefined` | `'numeric'` | no | Per-character pattern. String presets compile to internal RegExps; custom RegExp must match a single character. |
| `onComplete` | `((value: string) => boolean \| void \| PromiseLike<boolean \| void>) \| undefined` | — | no | Fire when the joined value first reaches `length`. Decisional — return / resolve `false` to reject (clears value, sets error). A rejected Promise is treated as `false` and logs a warning. |

## Methods

| Name | Type | Description |
|---|---|---|
| `write` | `(index: number, char: string) => void` | Write a single character at `index`. Empty string clears trailing characters from `index` onward. Out-of-range indices and characters rejected by `pattern` are ignored. No-ops while locked. |
| `distribute` | `(text: string, index?: number) => number` | Splice pattern-accepted characters from `text` into `value` starting at `index`. Returns the number of characters written. No-ops while locked or when no characters pass the pattern. |
| `clear` | `() => void` | Clear `value` and rejection state. No-ops while locked. |
| `fill` | `(text: string) => void` | Replace `value` with pattern-accepted characters from `text`, truncated to `length`. Clears rejection state on deliberate empty input or any accepted characters. No-ops while locked. |
| `accepts` | `(char: string) => boolean` | Whether `char` is a single character matching the current `pattern`. |

## Properties

| Name | Type | Description |
|---|---|---|
| `value` | `Readonly<Ref<string, string>>` | The joined OTP string. Use the mutation helpers (`write`, `distribute`, `fill`, `clear`) to update. Writing through this ref directly is intentionally prevented to preserve pattern, length, and lock invariants. |
| `length` | `Readonly<Ref<number, number>>` | Resolved character count from the `length` option. |
| `input` | `Omit<InputContext<string>, "value"> & { value: Readonly<Ref<string>>; }` | The underlying `createInput` context — exposes ARIA IDs, validation state, focus/touched, and the `validate` / `reset` methods.  Note: `input.value` aliases `OtpContext.value` and is also readonly on the public surface. Use the mutation helpers (`write`, `distribute`, `fill`, `clear`) to update. |
| `isComplete` | `Readonly<Ref<boolean, boolean>>` | True when `value` reaches `length` and every character matches `pattern`. |
| `isValidating` | `Readonly<Ref<boolean, boolean>>` | True while an async `onComplete` is in flight. Mutation helpers no-op during this window; consumers can render a spinner against this ref. |
