One-time code
OtpField. It is copied into your app’s ui/ by qatjs add otp: the code is yours to edit.
Example
Code empty
import OtpField from './ui/otp/otp.qx'
export default function Example() {
let code = state('')
let verified = state('')
return (
<OtpField label="Code from the SMS" bind:value={code} on:complete={(c) => (verified = c)} />
<p>
Code {code || 'empty'}
{verified ? `, verified ${verified}` : ''}
</p>
)
}code stateverified stateAdd it
npx qatjs add otpOtpField
As a custom element: <ui-otp-field>.
| Prop | Type | Attribute |
|---|---|---|
label | string | yes |
length | number | yes |
value | string | yes |
help | QatNode | property only |
error | QatNode | property only |
disabled | boolean | yes |
| Event | Detail |
|---|---|
on:update:value | CustomEvent<string> |
on:complete | CustomEvent<string> |
Keys
| Key | Does |
|---|---|
| digit | fills, moves on |
| Backspace | back from an empty cell |
| ← → | move |