Skip to content
UI

OTP Input

A one-time password input component for entering verification codes.

<script setup lang="ts">
import { OtpInput } from '@destyler-ui/vue'
</script>

<template>
  <OtpInput.Root>
    <OtpInput.Label>Label</OtpInput.Label>
    <OtpInput.Control>
      <OtpInput.Input v-for="id in [0, 1, 2]" :key="id" :index="id" />
    </OtpInput.Control>
    <OtpInput.HiddenInput />
  </OtpInput.Root>
</template>
import { OtpInput } from '@destyler-ui/react'

export function Basic() {
  return (
    <OtpInput.Root>
      <OtpInput.Label>Label</OtpInput.Label>
      <OtpInput.Control>
        <OtpInput.Input index={0} />
        <OtpInput.Input index={1} />
        <OtpInput.Input index={2} />
      </OtpInput.Control>
      <OtpInput.HiddenInput />
    </OtpInput.Root>
  )
}
import { OtpInput } from '@destyler-ui/solid/otp-input'
import { Index } from 'solid-js'

export function Basic() {
  return (
    <OtpInput.Root onValueComplete={e => console.warn(e.valueAsString)}>
      <OtpInput.Label>Label</OtpInput.Label>
      <OtpInput.Control>
        <Index each={[0, 1, 2]}>{id => <OtpInput.Input index={id()} />}</Index>
      </OtpInput.Control>
      <OtpInput.HiddenInput />
    </OtpInput.Root>
  )
}
<script module lang="ts">
  import type { OtpInputRootProps } from '@destyler-ui/svelte'

  export interface BasicProps extends OtpInputRootProps {}
</script>

<script lang="ts">
  import { OtpInput } from '@destyler-ui/svelte'

  const props: BasicProps = $props()
</script>

<OtpInput.Root {...props}>
  <OtpInput.Label>Label</OtpInput.Label>
  <OtpInput.Control>
    {#each [0, 1, 2] as index (index)}
      <OtpInput.Input {index} />
    {/each}
  </OtpInput.Control>
  <OtpInput.HiddenInput />
</OtpInput.Root>
<script setup lang="ts">
import { OtpInput } from '@destyler-ui/vue'
</script>
<template>
<OtpInput.Root>
<OtpInput.Label />
<OtpInput.Control>
<OtpInput.Input />
</OtpInput.Control>
<OtpInput.HiddenInput />
</OtpInput.Root>
</template>
import { OtpInput } from '@destyler-ui/react'
export default function Basic() {
return (
<OtpInput.Root>
<OtpInput.Label />
<OtpInput.Control>
<OtpInput.Input />
</OtpInput.Control>
<OtpInput.HiddenInput />
</OtpInput.Root>
)
}
import { OtpInput } from '@destyler-ui/solid'
export default function Basic() {
return (
<OtpInput.Root>
<OtpInput.Label />
<OtpInput.Control>
<OtpInput.Input index={0} />
</OtpInput.Control>
<OtpInput.HiddenInput />
</OtpInput.Root>
)
}
<script lang="ts">
import { OtpInput } from '@destyler-ui/svelte'
</script>
<OtpInput.Root>
<OtpInput.Label>Verification code</OtpInput.Label>
<OtpInput.Control>
{#each [0, 1, 2] as index (index)}
<OtpInput.Input {index} />
{/each}
</OtpInput.Control>
<OtpInput.HiddenInput />
</OtpInput.Root>
<script setup lang="ts">
import { OtpInput } from '@destyler-ui/vue'
</script>

<template>
  <OtpInput.Root>
    <OtpInput.Label>Label</OtpInput.Label>
    <OtpInput.Control>
      <OtpInput.Input v-for="id in [0, 1, 2]" :key="id" :index="id" />
    </OtpInput.Control>
    <OtpInput.HiddenInput />
  </OtpInput.Root>
</template>
import { OtpInput } from '@destyler-ui/react'

export function Basic() {
  return (
    <OtpInput.Root>
      <OtpInput.Label>Label</OtpInput.Label>
      <OtpInput.Control>
        <OtpInput.Input index={0} />
        <OtpInput.Input index={1} />
        <OtpInput.Input index={2} />
      </OtpInput.Control>
      <OtpInput.HiddenInput />
    </OtpInput.Root>
  )
}
import { OtpInput } from '@destyler-ui/solid/otp-input'
import { Index } from 'solid-js'

export function Basic() {
  return (
    <OtpInput.Root onValueComplete={e => console.warn(e.valueAsString)}>
      <OtpInput.Label>Label</OtpInput.Label>
      <OtpInput.Control>
        <Index each={[0, 1, 2]}>{id => <OtpInput.Input index={id()} />}</Index>
      </OtpInput.Control>
      <OtpInput.HiddenInput />
    </OtpInput.Root>
  )
}
<script module lang="ts">
  import type { OtpInputRootProps } from '@destyler-ui/svelte'

  export interface BasicProps extends OtpInputRootProps {}
</script>

<script lang="ts">
  import { OtpInput } from '@destyler-ui/svelte'

  const props: BasicProps = $props()
</script>

<OtpInput.Root {...props}>
  <OtpInput.Label>Label</OtpInput.Label>
  <OtpInput.Control>
    {#each [0, 1, 2] as index (index)}
      <OtpInput.Input {index} />
    {/each}
  </OtpInput.Control>
  <OtpInput.HiddenInput />
</OtpInput.Root>

Customize the OTP input appearance.

<script setup lang="ts">
import { OtpInput } from '@destyler-ui/vue'
</script>

<template>
  <OtpInput.Root placeholder="*">
    <OtpInput.Label>Label</OtpInput.Label>
    <OtpInput.Control>
      <OtpInput.Input v-for="id in [0, 1, 2]" :key="id" :index="id" />
    </OtpInput.Control>
    <OtpInput.HiddenInput />
  </OtpInput.Root>
</template>
import { OtpInput } from '@destyler-ui/react'

export function Customized() {
  return (
    <OtpInput.Root placeholder="*">
      <OtpInput.Label>Label</OtpInput.Label>
      <OtpInput.Control>
        <OtpInput.Input index={0} />
        <OtpInput.Input index={1} />
        <OtpInput.Input index={2} />
      </OtpInput.Control>
      <OtpInput.HiddenInput />
    </OtpInput.Root>
  )
}
import { OtpInput } from '@destyler-ui/solid/otp-input'
import { Index } from 'solid-js'

export function Customized() {
  return (
    <OtpInput.Root placeholder="*">
      <OtpInput.Label>Label</OtpInput.Label>
      <OtpInput.Control>
        <Index each={[0, 1, 2]}>{id => <OtpInput.Input index={id()} />}</Index>
      </OtpInput.Control>
      <OtpInput.HiddenInput />
    </OtpInput.Root>
  )
}
<script lang="ts">
  import { OtpInput } from '@destyler-ui/svelte'
</script>

<OtpInput.Root placeholder="*">
  <OtpInput.Label>Label</OtpInput.Label>
  <OtpInput.Control>
    {#each [0, 1, 2] as index (index)}
      <OtpInput.Input {index} />
    {/each}
  </OtpInput.Control>
  <OtpInput.HiddenInput />
</OtpInput.Root>

Set an initial value for the OTP input.

<script setup lang="ts">
import { OtpInput } from '@destyler-ui/vue'
</script>

<template>
  <OtpInput.Root :model-value="['1', '2', '3']">
    <OtpInput.Label>Label</OtpInput.Label>
    <OtpInput.Control>
      <OtpInput.Input v-for="id in [0, 1, 2]" :key="id" :index="id" />
    </OtpInput.Control>
    <OtpInput.HiddenInput />
  </OtpInput.Root>
</template>
import { OtpInput } from '@destyler-ui/react'

export function InitialValue() {
  return (
    <OtpInput.Root defaultValue={['1', '2', '3']}>
      <OtpInput.Label>Label</OtpInput.Label>
      <OtpInput.Control>
        <OtpInput.Input index={0} />
        <OtpInput.Input index={1} />
        <OtpInput.Input index={2} />
      </OtpInput.Control>
      <OtpInput.HiddenInput />
    </OtpInput.Root>
  )
}
import { OtpInput } from '@destyler-ui/solid/otp-input'
import { Index } from 'solid-js'

export function InitialValue() {
  return (
    <OtpInput.Root value={['1', '2', '3']}>
      <OtpInput.Label>Label</OtpInput.Label>
      <OtpInput.Control>
        <Index each={[0, 1, 2]}>{id => <OtpInput.Input index={id()} />}</Index>
      </OtpInput.Control>
      <OtpInput.HiddenInput />
    </OtpInput.Root>
  )
}
<script lang="ts">
  import { OtpInput } from '@destyler-ui/svelte'
</script>

<OtpInput.Root defaultValue={['1', '2', '3']}>
  <OtpInput.Label>Label</OtpInput.Label>
  <OtpInput.Control>
    {#each [0, 1, 2] as index (index)}
      <OtpInput.Input {index} />
    {/each}
  </OtpInput.Control>
  <OtpInput.HiddenInput />
</OtpInput.Root>

Enable OTP autocomplete mode.

<script setup lang="ts">
import { OtpInput } from '@destyler-ui/vue'
</script>

<template>
  <OtpInput.Root otp>
    <OtpInput.Label>Label</OtpInput.Label>
    <OtpInput.Control>
      <OtpInput.Input v-for="id in [0, 1, 2]" :key="id" :index="id" />
    </OtpInput.Control>
    <OtpInput.HiddenInput />
  </OtpInput.Root>
</template>
import { OtpInput } from '@destyler-ui/react'

export function OtpMode() {
  return (
    <OtpInput.Root otp>
      <OtpInput.Label>Label</OtpInput.Label>
      <OtpInput.Control>
        <OtpInput.Input index={0} />
        <OtpInput.Input index={1} />
        <OtpInput.Input index={2} />
      </OtpInput.Control>
      <OtpInput.HiddenInput />
    </OtpInput.Root>
  )
}
import { OtpInput } from '@destyler-ui/solid/otp-input'
import { Index } from 'solid-js'

export function OtpMode() {
  return (
    <OtpInput.Root otp>
      <OtpInput.Label>Label</OtpInput.Label>
      <OtpInput.Control>
        <Index each={[0, 1, 2]}>{id => <OtpInput.Input index={id()} />}</Index>
      </OtpInput.Control>
      <OtpInput.HiddenInput />
    </OtpInput.Root>
  )
}
<script lang="ts">
  import { OtpInput } from '@destyler-ui/svelte'
</script>

<OtpInput.Root otp>
  <OtpInput.Label>Label</OtpInput.Label>
  <OtpInput.Control>
    {#each [0, 1, 2] as index (index)}
      <OtpInput.Input {index} />
    {/each}
  </OtpInput.Control>
  <OtpInput.HiddenInput />
</OtpInput.Root>

Handle the blurred state.

<script setup lang="ts">
import { OtpInput } from '@destyler-ui/vue'
</script>

<template>
  <OtpInput.Root blurOnComplete>
    <OtpInput.Label>Label</OtpInput.Label>
    <OtpInput.Control>
      <OtpInput.Input v-for="id in [0, 1, 2]" :key="id" :index="id" />
    </OtpInput.Control>
    <OtpInput.HiddenInput />
  </OtpInput.Root>
</template>
import { OtpInput } from '@destyler-ui/react'

export function Blurred() {
  return (
    <OtpInput.Root blurOnComplete>
      <OtpInput.Label>Label</OtpInput.Label>
      <OtpInput.Control>
        <OtpInput.Input index={0} />
        <OtpInput.Input index={1} />
        <OtpInput.Input index={2} />
      </OtpInput.Control>
      <OtpInput.HiddenInput />
    </OtpInput.Root>
  )
}
import { OtpInput } from '@destyler-ui/solid/otp-input'
import { Index } from 'solid-js'

export function Blurred() {
  return (
    <OtpInput.Root blurOnComplete>
      <OtpInput.Label>Label</OtpInput.Label>
      <OtpInput.Control>
        <Index each={[0, 1, 2]}>{id => <OtpInput.Input index={id()} />}</Index>
      </OtpInput.Control>
      <OtpInput.HiddenInput />
    </OtpInput.Root>
  )
}
<script lang="ts">
  import { OtpInput } from '@destyler-ui/svelte'
</script>

<OtpInput.Root blurOnComplete>
  <OtpInput.Label>Label</OtpInput.Label>
  <OtpInput.Control>
    {#each [0, 1, 2] as index (index)}
      <OtpInput.Input {index} />
    {/each}
  </OtpInput.Control>
  <OtpInput.HiddenInput />
</OtpInput.Root>

Mask the input values for security.

<script setup lang="ts">
import { OtpInput } from '@destyler-ui/vue'
</script>

<template>
  <OtpInput.Root mask>
    <OtpInput.Label>Label</OtpInput.Label>
    <OtpInput.Control>
      <OtpInput.Input v-for="id in [0, 1, 2]" :key="id" :index="id" />
    </OtpInput.Control>
    <OtpInput.HiddenInput />
  </OtpInput.Root>
</template>
import { OtpInput } from '@destyler-ui/react'

export function WithMask() {
  return (
    <OtpInput.Root mask>
      <OtpInput.Label>Label</OtpInput.Label>
      <OtpInput.Control>
        <OtpInput.Input index={0} />
        <OtpInput.Input index={1} />
        <OtpInput.Input index={2} />
      </OtpInput.Control>
      <OtpInput.HiddenInput />
    </OtpInput.Root>
  )
}
import { OtpInput } from '@destyler-ui/solid/otp-input'
import { Index } from 'solid-js'

export function WithMask() {
  return (
    <OtpInput.Root mask>
      <OtpInput.Label>Label</OtpInput.Label>
      <OtpInput.Control>
        <Index each={[0, 1, 2]}>{id => <OtpInput.Input index={id()} />}</Index>
      </OtpInput.Control>
      <OtpInput.HiddenInput />
    </OtpInput.Root>
  )
}
<script lang="ts">
  import { OtpInput } from '@destyler-ui/svelte'
</script>

<OtpInput.Root mask>
  <OtpInput.Label>Label</OtpInput.Label>
  <OtpInput.Control>
    {#each [0, 1, 2] as index (index)}
      <OtpInput.Input {index} />
    {/each}
  </OtpInput.Control>
  <OtpInput.HiddenInput />
</OtpInput.Root>

Combine with a form field for validation and labeling.

<script setup lang="ts">
import { Field } from '@destyler-ui/vue'
import { OtpInput } from '@destyler-ui/vue'
</script>

<template>
  <Field.Root v-bind="$attrs">
    <OtpInput.Root v-bind="$attrs">
      <OtpInput.Label>Label</OtpInput.Label>
      <OtpInput.Control>
        <OtpInput.Input v-for="id in [0, 1, 2]" :key="id" :index="id" />
      </OtpInput.Control>
      <OtpInput.HiddenInput />
    </OtpInput.Root>
    <Field.HelperText>Additional Info</Field.HelperText>
    <Field.ErrorText>Error Info</Field.ErrorText>
  </Field.Root>
</template>
import { Field } from '@destyler-ui/react'
import { OtpInput } from '@destyler-ui/react'

interface WithFieldProps {
  disabled?: boolean
  readOnly?: boolean
  invalid?: boolean
}

export function WithField(props: WithFieldProps) {
  const { disabled, readOnly, invalid } = props

  return (
    <Field.Root disabled={disabled} readOnly={readOnly} invalid={invalid}>
      <OtpInput.Root>
        <OtpInput.Label>Label</OtpInput.Label>
        <OtpInput.Control>
          <OtpInput.Input index={0} />
          <OtpInput.Input index={1} />
          <OtpInput.Input index={2} />
        </OtpInput.Control>
        <OtpInput.HiddenInput />
      </OtpInput.Root>
      <Field.HelperText>Additional Info</Field.HelperText>
      <Field.ErrorText>Error Info</Field.ErrorText>
    </Field.Root>
  )
}
import { Field } from '@destyler-ui/solid/field'
import { OtpInput } from '@destyler-ui/solid/otp-input'
import { Index } from 'solid-js'

export function WithField(props: Field.RootProps) {
  return (
    <Field.Root {...props}>
      <OtpInput.Root>
        <OtpInput.Label>Label</OtpInput.Label>
        <OtpInput.Control>
          <Index each={[0, 1, 2]}>{id => <OtpInput.Input index={id()} />}</Index>
        </OtpInput.Control>
        <OtpInput.HiddenInput />
      </OtpInput.Root>
      <Field.HelperText>Additional Info</Field.HelperText>
      <Field.ErrorText>Error Info</Field.ErrorText>
    </Field.Root>
  )
}
<script module lang="ts">
  import type { FieldRootProps } from '@destyler-ui/svelte'

  export interface WithFieldProps extends FieldRootProps {}
</script>

<script lang="ts">
  import { Field } from '@destyler-ui/svelte'
  import { OtpInput } from '@destyler-ui/svelte'

  const props: WithFieldProps = $props()
</script>

<Field.Root {...props}>
  <OtpInput.Root>
    <OtpInput.Label>Label</OtpInput.Label>
    <OtpInput.Control>
      {#each [0, 1, 2] as index (index)}
        <OtpInput.Input {index} />
      {/each}
    </OtpInput.Control>
    <OtpInput.HiddenInput />
  </OtpInput.Root>
  <Field.HelperText>Additional Info</Field.HelperText>
  <Field.ErrorText>Error Info</Field.ErrorText>
</Field.Root>
<script setup lang="ts">
import { OtpInput, useOtpInput } from '@destyler-ui/vue'

const pinInput = useOtpInput()
</script>

<template>
  <button @click="pinInput.focus()">Focus</button>

  <OtpInput.RootProvider :value="pinInput">
    <OtpInput.Label>Label</OtpInput.Label>
    <OtpInput.Control>
      <OtpInput.Input v-for="id in [0, 1, 2]" :key="id" :index="id" />
    </OtpInput.Control>
    <OtpInput.HiddenInput />
  </OtpInput.RootProvider>
</template>
import { OtpInput, useOtpInput } from '@destyler-ui/react'

export function RootProvider() {
  const otpInput = useOtpInput()

  return (
    <>
      <button onClick={() => otpInput.focus()}>Focus</button>

      <OtpInput.RootProvider value={otpInput}>
        <OtpInput.Label>Label</OtpInput.Label>
        <OtpInput.Control>
          <OtpInput.Input index={0} />
          <OtpInput.Input index={1} />
          <OtpInput.Input index={2} />
        </OtpInput.Control>
        <OtpInput.HiddenInput />
      </OtpInput.RootProvider>
    </>
  )
}
import { OtpInput, useOtpInput } from '@destyler-ui/solid/otp-input'
import { Index } from 'solid-js'

export function RootProvider() {
  const otpInput = useOtpInput({ onValueComplete: e => console.warn(e.valueAsString) })

  return (
    <>
      <button onClick={() => otpInput().focus()}>Focus</button>

      <OtpInput.RootProvider value={otpInput}>
        <OtpInput.Label>Label</OtpInput.Label>
        <OtpInput.Control>
          <Index each={[0, 1, 2]}>{id => <OtpInput.Input index={id()} />}</Index>
        </OtpInput.Control>
        <OtpInput.HiddenInput />
      </OtpInput.RootProvider>
    </>
  )
}
<script lang="ts">
  import { OtpInput, useOtpInput } from '@destyler-ui/svelte'

  const id = $props.id()
  const otpInput = useOtpInput({ id })
</script>

<button type="button" onclick={() => otpInput().focus()}>Focus</button>

<OtpInput.RootProvider value={otpInput}>
  <OtpInput.Label>Label</OtpInput.Label>
  <OtpInput.Control>
    {#each [0, 1, 2] as index (index)}
      <OtpInput.Input {index} />
    {/each}
  </OtpInput.Control>
  <OtpInput.HiddenInput />
</OtpInput.RootProvider>

Root

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

autoFocusfalse | true

Whether to auto-focus the first input.

blurOnCompletefalse | true

Whether to blur the input when the value is complete

defaultValuestring[]

The initial value of the otp input when it is first rendered. Use when you do not need to control the state of the otp input.

disabledfalse | true

Whether the inputs are disabled

formstring

The associate form of the underlying input element.

idstring

The unique identifier of the machine.

idsPartial<{ root: string; hiddenInput: string; label: string; control: string; input: (id: string) => string; }>

The ids of the elements in the otp input. Useful for composition.

invalidfalse | true

Whether the otp input is in the invalid state

maskfalse | true

If `true`, the input's value will be masked just like `type=password`

modelValuestring[]
namestring

The name of the input element. Useful for form submission.

otpfalse | true

If `true`, the otp input component signals to its fields that they should use `autocomplete="one-time-code"`.

patternstring

The regular expression that the user-entered input value is checked against.

placeholder"○"string

The placeholder text for the input

readOnlyfalse | true

Whether the otp input is in the valid state

requiredfalse | true

Whether the otp input is required

selectOnFocusfalse | true

Whether to select input value when input is focused

translationsotpInput.IntlTranslations

Specifies the localized strings that identifies the accessibility elements and their states

type"numeric""numeric" | "alphanumeric" | "alphabetic"

The type of value the otp-input should allow

EmitEvent
update:modelValue[value: string[]]

The callback fired when the model value changes.

valueChange[details: ValueChangeDetails]

Function called on input change

valueComplete[details: ValueChangeDetails]

Function called when all inputs have valid values

valueInvalid[details: ValueInvalidDetails]

Function called when an invalid value is entered

Context

No serializable props or emits are declared for this part.

Control

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

HiddenInput

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

Input

PropDefaultType
index*number
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

Label

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

RootProvider

PropDefaultType
value*MachineApi<PropTypes>
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

Root

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

blurOnCompletefalse | true

Whether to blur the input when the value is complete

defaultValuestring[]

The initial value of the otp input when it is first rendered. Use when you do not need to control the state of the otp input

disabledfalse | true

Whether the inputs are disabled

formstring

The associate form of the underlying input element.

idsPartial<{ root: string; hiddenInput: string; label: string; control: string; input: (id: string) => string; }>

The ids of the elements in the pin input. Useful for composition.

invalidfalse | true

Whether the pin input is in the invalid state

maskfalse | true

If `true`, the input's value will be masked just like `type=password`

namestring

The name of the input element. Useful for form submission.

onValueChange(details: otpInput.ValueChangeDetails) => void

Function called on input change

onValueComplete(details: otpInput.ValueChangeDetails) => void

Function called when all inputs have valid values

onValueInvalid(details: ValueInvalidDetails) => void

Function called when an invalid value is entered

otpfalse | true

If `true`, the pin input component signals to its fields that they should use `autocomplete="one-time-code"`.

patternstring

The regular expression that the user-entered input value is checked against.

placeholder"○"string

The placeholder text for the input

readOnlyfalse | true

Whether the pin input is in the valid state

requiredfalse | true

Whether the pin input is required

selectOnFocusfalse | true

Whether to select input value when input is focused

translationsotpInput.IntlTranslations

Specifies the localized strings that identifies the accessibility elements and their states

type"numeric""numeric" | "alphanumeric" | "alphabetic"

The type of value the pin-input should allow

valuestring[]

The value of the the pin input.

Context

PropDefaultType
children*(context: UseOtpInputContext) => ReactNode

Control

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

HiddenInput

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

Input

PropDefaultType
index*number
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

Label

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

RootProvider

PropDefaultType
value*UseOtpInputReturn
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

Root

PropDefaultType
asChild(props: (userProps?: solid_js85.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.Element

Use the provided child element as the default rendered element, combining their props and behavior.

autoFocusfalse | true

Whether to auto-focus the first input.

blurOnCompletefalse | true

Whether to blur the input when the value is complete

defaultValuestring[]

The initial value of the pin input when it is first rendered. Use when you do not need to control the state of the pin input

disabledfalse | true

Whether the inputs are disabled

formstring

The associate form of the underlying input element.

idsPartial<{ root: string; hiddenInput: string; label: string; control: string; input: (id: string) => string; }>

The ids of the elements in the pin input. Useful for composition.

invalidfalse | true

Whether the pin input is in the invalid state

maskfalse | true

If `true`, the input's value will be masked just like `type=password`

namestring

The name of the input element. Useful for form submission.

onValueChange(details: ValueChangeDetails) => void

Function called on input change

onValueComplete(details: ValueChangeDetails) => void

Function called when all inputs have valid values

onValueInvalid(details: ValueInvalidDetails) => void

Function called when an invalid value is entered

otpfalse | true

If `true`, the pin input component signals to its fields that they should use `autocomplete="one-time-code"`.

patternstring

The regular expression that the user-entered input value is checked against.

placeholder"○"string

The placeholder text for the input

readOnlyfalse | true

Whether the pin input is in the valid state

requiredfalse | true

Whether the pin input is required

selectOnFocusfalse | true

Whether to select input value when input is focused

translationsotpInput.IntlTranslations

Specifies the localized strings that identifies the accessibility elements and their states

type"numeric""numeric" | "alphanumeric" | "alphabetic"

The type of value the pin-input should allow

valuestring[]

The value of the the pin input.

Context

PropDefaultType
children*(context: UseOtpInputContext) => Element

Control

PropDefaultType
asChild(props: (userProps?: solid_js85.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.Element

Use the provided child element as the default rendered element, combining their props and behavior.

HiddenInput

PropDefaultType
asChild(props: (userProps?: solid_js85.JSX.InputHTMLAttributes<HTMLInputElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.Element

Use the provided child element as the default rendered element, combining their props and behavior.

Input

PropDefaultType
index*number
asChild(props: (userProps?: solid_js85.JSX.InputHTMLAttributes<HTMLInputElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.Element

Use the provided child element as the default rendered element, combining their props and behavior.

Label

PropDefaultType
asChild(props: (userProps?: solid_js85.JSX.LabelHTMLAttributes<HTMLLabelElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.Element

Use the provided child element as the default rendered element, combining their props and behavior.

RootProvider

PropDefaultType
value*UseOtpInputReturn
asChild(props: (userProps?: solid_js85.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.Element

Use the provided child element as the default rendered element, combining their props and behavior.

Root

PropDefaultType
asChildSnippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]>
autoFocusfalse | true

Whether to auto-focus the first input.

blurOnCompletefalse | true

Whether to blur the input when the value is complete

childrenSnippet<[]> | undefined
defaultValuestring[]
disabledfalse | true

Whether the inputs are disabled

formstring

The associate form of the underlying input element.

idstring
idsPartial<{ root: string; hiddenInput: string; label: string; control: string; input: (id: string) => string; }>

The ids of the elements in the pin input. Useful for composition.

invalidfalse | true

Whether the pin input is in the invalid state

maskfalse | true

If `true`, the input's value will be masked just like `type=password`

namestring

The name of the input element. Useful for form submission.

onValueChange(details: import("/home/runner/work/ui/ui/packages/svelte/dist/index").OtpInputValueChangeDetails) => void

Function called on input change

onValueComplete(details: import("/home/runner/work/ui/ui/packages/svelte/dist/index").OtpInputValueChangeDetails) => void

Function called when all inputs have valid values

onValueInvalid(details: import("/home/runner/work/ui/ui/packages/svelte/dist/index").OtpInputValueInvalidDetails) => void

Function called when an invalid value is entered

otpfalse | true

If `true`, the pin input component signals to its fields that they should use `autocomplete="one-time-code"`.

patternstring

The regular expression that the user-entered input value is checked against.

placeholder"○"string

The placeholder text for the input

readOnlyfalse | true

Whether the pin input is in the valid state

requiredfalse | true

Whether the pin input is required

selectOnFocusfalse | true

Whether to select input value when input is focused

translationsIntlTranslations | undefined

Specifies the localized strings that identifies the accessibility elements and their states

type"numeric""numeric" | "alphanumeric" | "alphabetic"

The type of value the pin-input should allow

valuestring[]

The value of the the pin input.

Context

PropDefaultType
renderSnippet<[UseOtpInputContext]>

Control

PropDefaultType
asChildimport("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]>
childrenSnippet<[]> | undefined

HiddenInput

PropDefaultType
asChildimport("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"input">]>
childrenSnippet<[]> | undefined

Input

PropDefaultType
index*number
asChildimport("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"input">]>
childrenSnippet<[]> | undefined

Label

PropDefaultType
asChildimport("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"label">]>
childrenSnippet<[]> | undefined

RootProvider

PropDefaultType
value*UseOtpInputReturn
asChildSnippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]>
childrenSnippet<[]> | undefined