# Input OTP

Accessible one-time password component with copy-paste functionality.

Section: Components / Inputs
Page: https://ui.heyramzi.com/components/input-otp
Import path: `@heyramzi/ui/shadcn/input-otp`

## Import

```ts
import * as InputOTP from "@heyramzi/ui/shadcn/input-otp";
```

## Usage

```svelte
<InputOTP.Root maxlength={6} aria-label="Verification code">
  {#snippet children({ cells })}
    <InputOTP.Group>
      {#each cells.slice(0, 3) as cell (cell)}
        <InputOTP.Slot {cell} />
      {/each}
    </InputOTP.Group>
    <InputOTP.Separator />
    <InputOTP.Group>
      {#each cells.slice(3, 6) as cell (cell)}
        <InputOTP.Slot {cell} />
      {/each}
    </InputOTP.Group>
  {/snippet}
</InputOTP.Root>
```

## Demo

```svelte
<script lang="ts">
	import * as InputOTP from "@heyramzi/ui/shadcn/input-otp";
</script>

<InputOTP.Root maxlength={6} aria-label="Verification code">
	{#snippet children({ cells })}
		<InputOTP.Group>
			{#each cells.slice(0, 3) as cell (cell)}
				<InputOTP.Slot {cell} />
			{/each}
		</InputOTP.Group>
		<InputOTP.Separator />
		<InputOTP.Group>
			{#each cells.slice(3, 6) as cell (cell)}
				<InputOTP.Slot {cell} />
			{/each}
		</InputOTP.Group>
	{/snippet}
</InputOTP.Root>
```

## API

### InputOTP.Root

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `inputRef` |  | `null` | bindable |
| `class` | `string` |  |  |
| `value` | `string` | `""` | bindable |

Every prop of `PinInput.Root` from `bits-ui`.

### InputOTP.Group

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLDivElement \| null` | `null` | bindable |
| `class` | `string` |  |  |
| `children` | `Snippet` |  |  |

Every prop of `HTMLAttributes<HTMLDivElement>` from `svelte/elements`.

### InputOTP.Slot

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLElement \| null` | `null` | bindable |
| `cell` |  |  |  |
| `class` | `string` |  |  |

Every prop of `PinInput.Cell` from `bits-ui`.

### InputOTP.Separator

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `ref` | `HTMLDivElement \| null` | `null` | bindable |
| `children` | `Snippet` |  |  |

Every prop of `HTMLAttributes<HTMLDivElement>` from `svelte/elements`.
