Formulários
VOtpInput
Campo de código de verificação com input lógico único, slots visuais, colar código completo e auto-submit.
<script setup lang="ts">
import { VOtpInput } from 'vueui-nova-kit'
</script>Uso
<script setup lang="ts">
</script>
<template>
</template>Playground
Os controles abaixo são gerados a partir das props declaradas em VOtpInput.types.ts; o código acompanha cada mudança.
Exemplos
Variantes, tamanhos e estados, extraídos das stories da biblioteca.
Default
Variação Padrão. Estado padrão do componente; use a aba Controls para experimentar as props ao vivo. Props: modelValue="240186".
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VOtpInput } from 'vueui-nova-kit'
const value = ref('240186')
</script>
<template>
<VOtpInput v-model="value" />
</template>Four Digits
Variação Four Digits. Props: length=4, modelValue="1234".
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VOtpInput } from 'vueui-nova-kit'
const value = ref('1234')
</script>
<template>
<VOtpInput v-model="value" :length="4" />
</template>Masked
Variação Masked. Props: masked=true, modelValue="123456".
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VOtpInput } from 'vueui-nova-kit'
const value = ref('123456')
</script>
<template>
<VOtpInput v-model="value" masked />
</template>Error
Variação Erro. Props: modelValue="123", errorMessage="Invalid verification code".
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VOtpInput } from 'vueui-nova-kit'
const value = ref('123')
</script>
<template>
<VOtpInput v-model="value" error-message="Invalid verification code" />
</template>Success
Variação Sucesso. Props: modelValue="240186", success=true.
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VOtpInput } from 'vueui-nova-kit'
const value = ref('240186')
</script>
<template>
<VOtpInput v-model="value" success />
</template>With Resend
Variação Com Resend. Props: helperText="Didn't receive the code?", resendLabel="Resend code", resendCooldown=23.
Ver código
<script setup lang="ts">
import { VOtpInput } from 'vueui-nova-kit'
</script>
<template>
<VOtpInput
v-model="value"
helper-text="Didn't receive the code?"
:resend-cooldown="23" />
</template>Interactive
Variação Interativo. Interativo: o estado é mantido na própria story (v-model).
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VOtpInput } from 'vueui-nova-kit'
const code = ref('')
const onComplete = (value) => {
console.log("complete", value);
}
</script>
<template>
<VOtpInput
v-model="code"
auto-submit
helper-text="We've sent a 6-digit code to alex@company.com."
resend-label="Resend code"
:resend-cooldown="23"
@complete="onComplete" />
</template>Auto Submit
Variação Auto Submit. Props: length=6, autoSubmit=true, helperText="Envia ao completar os 6 díg…".
Ver código
<script setup lang="ts">
import { VOtpInput } from 'vueui-nova-kit'
</script>
<template>
<VOtpInput
v-model="value"
auto-submit
helper-text="Envia ao completar os 6 dígitos" />
</template>Separator Index
Variação Separator Index. Props: length=6, separatorIndex=3.
Ver código
<script setup lang="ts">
import { VOtpInput } from 'vueui-nova-kit'
</script>
<template>
<VOtpInput v-model="value" :separator-index="3" />
</template>Disabled
Variação Desabilitado. Props: length=6, disabled=true, modelValue="123".
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VOtpInput } from 'vueui-nova-kit'
const value = ref('123')
</script>
<template>
<VOtpInput v-model="value" disabled />
</template>Acessibilidade
Input lógico único com inputmode="numeric" e autocomplete="one-time-code", slots aria-hidden, erro com role="alert".
Estados
Empty · Active · Filled · Error · Success · Disabled.
Motion
| Trigger | Property | Duration | Easing |
|---|---|---|---|
| Focus ring | box-shadow | 100ms | ease-out |
| Error | translateX shake | 280ms | ease-out |
| Success | opacity | 100ms | ease-out |
Respeitar prefers-reduced-motion.
Todas as transições respeitam prefers-reduced-motion e os tokens --v-duration-*.
Props
| Prop | Tipo | Default | Descrição |
|---|---|---|---|
modelValue | string | "" | — |
length | number | 6 | — |
masked | boolean | false | — |
autoSubmit | boolean | false | — |
disabled | boolean | false | — |
errorMessage | string | — | — |
success | boolean | false | — |
size | VOtpInputSize | "md" | — |
separatorIndex | number | — | — |
helperText | string | — | — |
resendLabel | string | "Resend code" | — |
resendCooldown | number | 0 | — |
ariaLabel | string | "Verification code" | — |
id | string | — | — |
motion | VMotionLevel | V_MOTION_DEFAULT ("expressive") | — |
Events
| Evento | Payload | Descrição |
|---|---|---|
@update:modelValue | value: string | — |
@complete | value: string | — |
@resend | — | — |
@focus | payload: FocusEvent | — |
@blur | payload: FocusEvent | — |
Slots
Sem slots.
Fonte: src/components/form/VOtpInput/VOtpInput.vue · tipos: src/components/form/VOtpInput/VOtpInput.types.ts