Search 71 components and 72 controllers by name, category or description.
Input OTP
Numeric one-time code input with visual segments, native autofill, Laravel validation and opt-in submit on completion
Try the examples with the fixed demo code 001234. This is not a real authentication service, and submitted codes are not stored.
View documentationSubmit and validate in a Turbo Frame
Enter 001234 to verify a code without leaving the page. Try another code to see an inline validation error.
<hw:frame id="otp-verification">
<div class="grid gap-4" data-turbo-temporary>
@if ($otpVerified ?? false)
<hw:alert role="status">Code verified. Nothing was stored.</hw:alert>
@endif
<hw:form id="otp-verification-form" :action="route('components.input-otp.verify')" method="post" frame="otp-verification">
<hw:field name="code" label="Authenticator code" description="Enter 001234 to verify this demonstration." required>
<hw:input-otp />
</hw:field>
<div class="mt-4 flex gap-2">
<hw:button type="submit">Verify code</hw:button>
<hw:button type="reset" variant="outline">Reset code</hw:button>
</div>
</hw:form>
</div>
</hw:frame>
Lengths and native states
Choose a code length and use familiar readonly, disabled and reset behavior.
<hw:form id="otp-states" class="grid gap-5">
<hw:field name="short_code" label="Four-digit code">
<hw:input-otp :length="4" value="0012" />
</hw:field>
<hw:field name="readonly_code" label="Readonly code">
<hw:input-otp readonly value="012345" />
</hw:field>
<hw:field name="disabled_code" label="Disabled code">
<hw:input-otp disabled value="012345" />
</hw:field>
<hw:button type="reset" variant="outline">Reset states</hw:button>
</hw:form>
Submit on completion
Verify a completed code automatically, or use the submit button. Automatic submission is opt-in.
<hw:frame id="otp-auto-verification">
<div class="grid gap-4" data-turbo-temporary>
@if ($otpAutomaticVerified ?? false)
<hw:alert role="status">Code verified. Nothing was stored.</hw:alert>
@endif
<hw:form id="otp-auto-submit" :action="route('components.input-otp.auto-verify')" method="post" frame="otp-auto-verification" auto-submit>
<hw:field name="automatic_code" label="Automatic verification" required>
<hw:input-otp auto-submit />
</hw:field>
<hw:button class="mt-4" type="submit" variant="outline">Verify automatically or submit</hw:button>
</hw:form>
</div>
</hw:frame>
Inside a Modal
Enter and select digits without leaving the dialog. Escape closes the dialog and returns to its trigger.
Verify in a Modal
Try typing, pasting, selecting digits and pressing Escape.
<hw:modal id="otp-modal" initial-focus="first-focusable">
<hw:modal.trigger>Open OTP modal</hw:modal.trigger>
<hw:modal.content>
<hw:modal.header>
<hw:modal.title>Verify in a Modal</hw:modal.title>
<hw:modal.description>Try typing, pasting, selecting digits and pressing Escape.</hw:modal.description>
</hw:modal.header>
<div class="p-4">
<hw:field name="modal_code" label="Modal code">
<hw:input-otp />
</hw:field>
</div>
</hw:modal.content>
</hw:modal>
Inside a Dropdown
Verify a code inside an interactive menu that stays open while you type.
<hw:dropdown :close-on-select="false">
<hw:dropdown.trigger>Open OTP dropdown</hw:dropdown.trigger>
<hw:dropdown.content width="w-80 max-w-[calc(100vw-2rem)]">
<div class="grid gap-4 p-2">
<hw:field name="dropdown_code" label="Dropdown code">
<hw:input-otp />
</hw:field>
<hw:button type="button" variant="outline" data-action="dropdown#close">Done</hw:button>
</div>
</hw:dropdown.content>
</hw:dropdown>