Skip to main content

Otp Input

Rocket 2.0

The Otp Input component collects a short one-time code, one character per box, such as a sign-in or verification code. It accepts pasted codes and the phone's code autofill.

Properties​

Property
Description
Expected Value
LabelText shown above the boxes.Text. Default: Verification code
Help textHint text shown under the boxes.Text
Length (4 to 8)Number of boxes, from 4 to 8. A partly filled code shows an error asking for all the characters.Number. Default: 6
CharactersWhich characters the boxes accept. Digits takes only numbers; Letters and digits also takes letters, shown in uppercase.Digits, Letters and digits. Default: Digits
Separator in the middleSplits the boxes into two halves with a dash between them.On or off. Default: Off
BoxesJoined draws the boxes as one connected strip; Separate spaces them apart.Joined, Separate. Default: Joined
Mask charactersShows a dot in each filled box instead of the character.On or off. Default: Off
Placeholder (one character per box)Hint shown in empty boxes, one character per box. A single character is shown in every box.Text
Default valueCode filled in when the app loads.Text

Additional Actions​

Each of these can be switched on or off, or set with a logical expression by clicking fx.

Property
Description
Expected Value
VisibilityShows or hides the component. Hidden components keep their space unless Collapse when hidden is on.On or off. Default: On
Collapse when hiddenRemoves the hidden component's space, so the components below it move up.On or off. Default: Off
Loading stateShows the component's loading look and blocks interaction, for example while a query runs.On or off. Default: Off
DisableStops the user from interacting with the component.On or off. Default: Off
Dynamic heightLets the component grow with its content in the running app instead of keeping a fixed height.On or off. Default: Off

Devices​

Property
Description
Expected Value
Show on desktopShows the component in the desktop layout.On or off. Default: On
Show on mobileShows the component in the mobile layout.On or off. Default: Off

Events​

Add a handler from the Events section of the properties panel. See Event Triggers for the steps.

Event
Description
On changeTriggers when the code changes.
On completeTriggers when the user fills the last empty box.
On focusTriggers when the boxes get focus.
On blurTriggers when the boxes lose focus.

Component Specific Actions (CSA)​

Run these from an event handler with Control Component, or from a RunJS query. See Component Specific Actions.

Action
Description
How To Access
ClearEmpties all the boxes.components.otpinput1.clear()
Set focusMoves keyboard focus to the first empty box.components.otpinput1.setFocus()
Set blurRemoves focus from the boxes.components.otpinput1.setBlur()
Set textFills the boxes with the given Value. Characters the boxes don't accept are dropped.components.otpinput1.setText("")
Set visibilityShows the component when true, hides it when false.components.otpinput1.setVisibility(false)
Set disableDisables the component when true, enables it when false.components.otpinput1.setDisable(false)
Set loadingTurns the loading state on with true, off with false.components.otpinput1.setLoading(false)

Exposed Variables​

Variable
Description
How To Access
labelText shown above the boxes.{{components.otpinput1.label}}
descriptionHint text shown under the boxes.{{components.otpinput1.description}}
lengthNumber of boxes, from 4 to 8. A partly filled code shows an error asking for all the characters.{{components.otpinput1.length}}
charactersWhich characters the boxes accept. Digits takes only numbers; Letters and digits also takes letters, shown in uppercase.{{components.otpinput1.characters}}
separatorSplits the boxes into two halves with a dash between them.{{components.otpinput1.separator}}
slotStyleJoined draws the boxes as one connected strip; Separate spaces them apart.{{components.otpinput1.slotStyle}}
maskedShows a dot in each filled box instead of the character.{{components.otpinput1.masked}}
placeholderHint shown in empty boxes, one character per box. A single character is shown in every box.{{components.otpinput1.placeholder}}
defaultValueCode filled in when the app loads.{{components.otpinput1.defaultValue}}
valueThe code entered so far.{{components.otpinput1.value}}
isCompleteWhether every box is filled.{{components.otpinput1.isComplete}}
isVisibleWhether the component is visible.{{components.otpinput1.isVisible}}
isLoadingWhether the component is in its loading state.{{components.otpinput1.isLoading}}
isDisabledWhether the component is disabled.{{components.otpinput1.isDisabled}}

Styles​

Style
Default
Label colorTheme: Primary text
Help text colorTheme: Placeholder text
Field backgroundTheme: Surface 1
Field text colorTheme: Primary text
Placeholder colorTheme: Placeholder text
Field border colorTheme: Default border
Accent (focus ring, selection)Theme: Brand primary
Error color (message and border)Theme: Error
Field radius—
Separator colorTheme: Placeholder text
Box size36
Box shadow0px 0px 0px 0px #00000040

A default that starts with Theme: follows the app's theme until the style is set to another value. See App Themes.