qat

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

Example.qx13 lines, 2 reactive namesOpen in the playground
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 state

Add it

shell1 line
npx qatjs add otp

OtpField

As a custom element: <ui-otp-field>.

OtpField: props
PropTypeAttribute
labelstringyes
lengthnumberyes
valuestringyes
helpQatNodeproperty only
errorQatNodeproperty only
disabledbooleanyes
OtpField: events
EventDetail
on:update:valueCustomEvent<string>
on:completeCustomEvent<string>

Keys

KeyDoes
digitfills, moves on
Backspaceback from an empty cell
← →move