Use for entering a short one-time verification code.
The q2-otp element has one or more properties that support text localization. Those properties are indicated by the localizable badge in the description.
autoFocusauto-focusFocuses the first one-time password field when the component loads.
autoSubmitauto-submitEmits submission event when the last field is filled.
clearOnErrorclear-on-errorClears all fields and returns focus to the first field when state becomes error.
disabledDisables all one-time password fields.
errorMessageerror-messageError message rendered below the submit area.
helperTexthelper-textHelper text content.
labelVisible label above the one-time password fields.
lengthNumber of one-time password fields. Use a number for ungrouped fields or an array for grouped fields with dash separators.
maskedObscures entered characters.
processingLabelprocessing-labelButton text during processing.
sendCodeLabelsend-code-labelButton text for the send-code action.
showHelperTextshow-helper-textToggles helper text visibility.
showSendCodeshow-send-codeToggles visibility of the send-code button while state is ready.
stateSets the visual status for the one-time password fields.
ready — Shows the send-code button when showSendCode is enabled and hides the input fields until the user
requests a code.error — Displays an error style on the fields. If errorMessage is set, it renders below the submit area.
When clearOnError is enabled, all fields are cleared and focus returns to the first field.success — Locks the input, replaces the submit button with a success indicator, and displays the
successMessage if provided.verifying — Locks the input and puts the submit button into a loading state. When combined with autoSubmit,
a processing overlay with processingLabel is shown over the fields.submitLabelsubmit-labelRenders a submit button with this label.
successMessagesuccess-messageSuccess message rendered below the submit area.
valueThe composed one-time password value.
The q2-otp element exposes events that can be used to send and receive data from the component based on user interaction.
Emitted when the fields are cleared.
{ value: string; }Emitted when all fields are filled.
{ value: string; }Emitted when any field value changes.
{ value: string; }Emitted when the send-code button is clicked.
voidEmitted when the submit button is clicked or auto-submit triggers.
{ value: string; }The q2-otp element exposes methods that can be used to perform various actions on the component.
Clears all fields, focuses the first field, and emits tctClear.
clear() => Promise<void>Clears the component and resets error, success, and processing state.
reset() => Promise<void>The following CSS variables are available to override the default theme styles of the q2-otp component.
Many Tecton components consume other components to maintain visual and functional consistency. If you are looking for a CSS variable you think should exist but are not seeing it, it may be defined in one of the dependent components below. Either way, if you think it's something we should expose more conveniently, let us know!
This component uses other components in the Tecton library, including:
q2-messageq2-loadingq2-btnq2-iconThe changelog provides a detailed history of new features, improvements, and bug fixes going back to Tecton 1.30.0. If the button is disabled, it indicates there have been no detectable changes since then.