- Prop
length- Type
number | undefined- Default
- —
- Requirement
- optional
Docs Components Forms
InputOTP
React example follows below.
Vue example follows below.
Angular example follows below.
Svelte example follows below.
Solid example follows below.
- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
const inputOtpFixture = { id: "inputotp", length: 6, // Four of six boxes filled, so every adapter's demo shows the same // half-filled state: the filled prefix, two empty boxes, and the caret // position the paste/backspace helpers key off. otpValue: "4821", label: "One-time code",} satisfies { id: string; length: number; otpValue: string; label: string;}; import { InputOTP } from "@grassroot/ui-react"; export default function InputOTPDemo() { return ( <div> <InputOTP length={inputOtpFixture.length} defaultValue={inputOtpFixture.otpValue} label={inputOtpFixture.label} /> </div> );}- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
<script setup lang="ts">import { ref } from "vue";const inputOtpFixture = { id: "inputotp", length: 6, // Four of six boxes filled, so every adapter's demo shows the same // half-filled state: the filled prefix, two empty boxes, and the caret // position the paste/backspace helpers key off. otpValue: "4821", label: "One-time code",} satisfies { id: string; length: number; otpValue: string; label: string;}; import { InputOTP } from "@grassroot/ui-vue";const otp = ref(inputOtpFixture.otpValue);</script><template> <div> <InputOTP v-model="otp" :length="inputOtpFixture.length" :label="inputOtpFixture.label" /> </div></template>- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
import { Component } from "@angular/core";const inputOtpFixture = { id: "inputotp", length: 6, // Four of six boxes filled, so every adapter's demo shows the same // half-filled state: the filled prefix, two empty boxes, and the caret // position the paste/backspace helpers key off. otpValue: "4821", label: "One-time code",} satisfies { id: string; length: number; otpValue: string; label: string;}; import { GrassrootInputOTP } from "@grassroot/ui-angular";@Component({ selector: "app-input-otp-demo", standalone: true, imports: [GrassrootInputOTP], template: `<div> <grassroot-input-otp [length]="fixture.length" [value]="fixture.otpValue" [label]="fixture.label" /> </div>`,})export class InputOTPDemoComponent { protected readonly fixture = inputOtpFixture;}export default InputOTPDemoComponent;- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
<script lang="ts"> const inputOtpFixture = { id: "inputotp", length: 6, // Four of six boxes filled, so every adapter's demo shows the same // half-filled state: the filled prefix, two empty boxes, and the caret // position the paste/backspace helpers key off. otpValue: "4821", label: "One-time code", } satisfies { id: string; length: number; otpValue: string; label: string; }; import { InputOTP } from "@grassroot/ui-svelte";</script> <div> <InputOTP length={inputOtpFixture.length} defaultValue={inputOtpFixture.otpValue} label={inputOtpFixture.label} /></div>- parts
- —
- nodes
- —
- size
- —
- part
- —
ts
/** @jsxImportSource solid-js */const inputOtpFixture = { id: "inputotp", length: 6, // Four of six boxes filled, so every adapter's demo shows the same // half-filled state: the filled prefix, two empty boxes, and the caret // position the paste/backspace helpers key off. otpValue: "4821", label: "One-time code",} satisfies { id: string; length: number; otpValue: string; label: string;}; import { InputOTP } from "@grassroot/ui-solid";export default function InputOTPDemo() { return ( <div> <InputOTP length={inputOtpFixture.length} defaultValue={inputOtpFixture.otpValue} label={inputOtpFixture.label} /> </div> );}Installation
API Reference
Import
import { InputOTP } from "@grassroot/ui-react";
Props
Prop
Type
Default
Requirement
lengthnumber | undefined—
optional
valuestring | undefined—
optional
defaultValuestring | undefined—
optional
onValueChange((value: string) => void) | undefined—
optional
onComplete((value: string) => void) | undefined—
optional
labelstring | undefined—
optional
disabledboolean | undefined—
optional
classNamestring | undefined—
optional
- Prop
value- Type
string | undefined- Default
- —
- Requirement
- optional
- Prop
defaultValue- Type
string | undefined- Default
- —
- Requirement
- optional
- Prop
onValueChange- Type
((value: string) => void) | undefined- Default
- —
- Requirement
- optional
- Prop
onComplete- Type
((value: string) => void) | undefined- Default
- —
- Requirement
- optional
- Prop
label- Type
string | undefined- Default
- —
- Requirement
- optional
- Prop
disabled- Type
boolean | undefined- Default
- —
- Requirement
- optional
- Prop
className- Type
string | undefined- Default
- —
- Requirement
- optional
Events
| Event | Payload |
|---|---|
onValueChange | ((value: string) => void) | undefined |
onComplete | ((value: string) => void) | undefined |
Import
import { ref } from "vue";
import { InputOTP } from "@grassroot/ui-vue";
Props
Prop
Type
Default
Requirement
lengthnumber | undefined6optional
modelValuestring | undefined""optional
labelstring | undefined"One-time code"optional
disabledboolean | undefinedfalseoptional
- Prop
length- Type
number | undefined- Default
6- Requirement
- optional
- Prop
modelValue- Type
string | undefined- Default
""- Requirement
- optional
- Prop
label- Type
string | undefined- Default
"One-time code"- Requirement
- optional
- Prop
disabled- Type
boolean | undefined- Default
false- Requirement
- optional
Events
| Event | Payload |
|---|---|
update:modelValue | [value: string] |
complete | [value: string] |
Import
import { Component } from "@angular/core";
import { GrassrootInputOTP } from "@grassroot/ui-angular";
Props
Prop
Type
Default
Requirement
lengthnumber6optional
valuestring""optional
labelstring"One-time code"optional
disabledbooleanfalseoptional
- Prop
length- Type
number- Default
6- Requirement
- optional
- Prop
value- Type
string- Default
""- Requirement
- optional
- Prop
label- Type
string- Default
"One-time code"- Requirement
- optional
- Prop
disabled- Type
boolean- Default
false- Requirement
- optional
Events
| Event | Payload |
|---|---|
valueChange | string |
complete | string |
Import
import { InputOTP } from "@grassroot/ui-svelte";
Props
Prop
Type
Default
Requirement
lengthnumber6optional
valuestring—
optional
defaultValuestring""optional
labelstring"One-time code"optional
disabledbooleanfalseoptional
classNamestring—
optional
onValueChange(value: string) => void—
optional
onComplete(value: string) => void—
optional
- Prop
length- Type
number- Default
6- Requirement
- optional
- Prop
value- Type
string- Default
- —
- Requirement
- optional
- Prop
defaultValue- Type
string- Default
""- Requirement
- optional
- Prop
label- Type
string- Default
"One-time code"- Requirement
- optional
- Prop
disabled- Type
boolean- Default
false- Requirement
- optional
- Prop
className- Type
string- Default
- —
- Requirement
- optional
- Prop
onValueChange- Type
(value: string) => void- Default
- —
- Requirement
- optional
- Prop
onComplete- Type
(value: string) => void- Default
- —
- Requirement
- optional
Events
| Event | Payload |
|---|---|
onValueChange | (value: string) => void |
onComplete | (value: string) => void |
Import
import { InputOTP } from "@grassroot/ui-solid";
Props
Prop
Type
Default
Requirement
lengthnumber6optional
valuestring—
optional
defaultValuestring—
optional
onValueChange(value: string) => void—
optional
onComplete(value: string) => void—
optional
labelstring"One-time code"optional
disabledboolean—
optional
classNamestring—
optional
- Prop
length- Type
number- Default
6- Requirement
- optional
- Prop
value- Type
string- Default
- —
- Requirement
- optional
- Prop
defaultValue- Type
string- Default
- —
- Requirement
- optional
- Prop
onValueChange- Type
(value: string) => void- Default
- —
- Requirement
- optional
- Prop
onComplete- Type
(value: string) => void- Default
- —
- Requirement
- optional
- Prop
label- Type
string- Default
"One-time code"- Requirement
- optional
- Prop
disabled- Type
boolean- Default
- —
- Requirement
- optional
- Prop
className- Type
string- Default
- —
- Requirement
- optional
Events
| Event | Payload |
|---|---|
onValueChange | (value: string) => void |
onComplete | (value: string) => void |