# Input OTP: Form

> With a `name`, the code is submitted with the form. `autoSubmit` submits as soon as the last slot fills, so an autofilled code signs people in without another tap.

Example: https://hextaui.com/docs/input-otp/examples/form
Component docs: https://hextaui.com/docs/input-otp.md

## Add this example

```bash
npx shadcn@latest add https://hextaui.com/r/input-otp-form.json
```

This adds `components/examples/input-otp/form.tsx` with the Input OTP component and the HextaUI theme tokens.

## Source

```tsx title="components/examples/input-otp/form.tsx"
"use client"

import * as React from "react"

import { Button } from "@/components/ui/button"
import {
  InputOTP,
  InputOTPGroup,
  InputOTPSlot,
} from "@/components/ui/input-otp"
import { Label } from "@/components/ui/label"

export function InputOTPForm() {
  const [submitted, setSubmitted] = React.useState<string>()

  return (
    <form
      className="flex max-w-full min-w-0 flex-col items-start gap-3"
      onSubmit={(event) => {
        event.preventDefault()
        setSubmitted(String(new FormData(event.currentTarget).get("code")))
      }}
    >
      <Label htmlFor="input-otp-form">Sign-in code</Label>
      <InputOTP id="input-otp-form" name="code" length={6} required autoSubmit>
        <InputOTPGroup>
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPSlot />
        </InputOTPGroup>
      </InputOTP>
      <div className="flex items-center gap-3">
        <Button type="submit" size="sm">
          Continue
        </Button>
        <p role="status" className="text-sm text-muted-foreground tabular-nums">
          {submitted ? `Submitted ${submitted}` : null}
        </p>
      </div>
    </form>
  )
}
```

## Props in this example

### InputOTP

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `length` | `number` | – | Required. The number of slots; render the same number of InputOTPSlot parts. |
| `autoSubmit` | `boolean` | `false` |  |
| `name` | `string` | – |  |
| `id` | `string` | – | Goes on the first slot, so a label's htmlFor points at it. |
| `required` | `boolean` | `false` |  |

## More Input OTP examples

- [Joined](https://hextaui.com/docs/input-otp/examples/basic.md)
- [Separate](https://hextaui.com/docs/input-otp/examples/separate.md)
- [Sizes](https://hextaui.com/docs/input-otp/examples/sizes.md)
- [Animated](https://hextaui.com/docs/input-otp/examples/animated.md)
- [Status](https://hextaui.com/docs/input-otp/examples/status.md)
- [Controlled](https://hextaui.com/docs/input-otp/examples/controlled.md)
- [With Field](https://hextaui.com/docs/input-otp/examples/field.md)
- [Invalid](https://hextaui.com/docs/input-otp/examples/invalid.md)
- [Letters and numbers](https://hextaui.com/docs/input-otp/examples/alphanumeric.md)
- [Masked](https://hextaui.com/docs/input-otp/examples/masked.md)
- [Custom separator](https://hextaui.com/docs/input-otp/examples/custom-separator.md)
- [Disabled](https://hextaui.com/docs/input-otp/examples/disabled.md)
- [Right to left](https://hextaui.com/docs/input-otp/examples/rtl.md)
