A shadcn OTP input: one real hidden input overlays a row of rendered cells.
input$<inputId> is the string as typed (may be partial).
Usage
shad_input_otp(
inputId,
length = 6,
groups = NULL,
label = NULL,
value = NULL,
pattern = c("numeric", "alphanumeric"),
disabled = FALSE,
class = NULL,
...
)Arguments
- inputId
Input id.
- length
Total number of cells / code length.
- groups
Optional integer vector splitting cells into groups separated by a divider (e.g.
c(3, 3)). Must sum tolength.- label
Optional label (wraps in
shad_form_field()).- value
Optional initial code (also restored on bookmark reload).
- pattern
"numeric"(digits only) or"alphanumeric"(any character).- disabled
If
TRUE, disables the control.- class
Extra CSS classes.
- ...
Extra attributes on the OTP root.
See also
Other shadshiny tier-2 components:
shad_calendar(),
shad_checkbox(),
shad_combobox(),
shad_date_picker(),
shad_date_presets(),
shad_form_field(),
shad_input(),
shad_input_group(),
shad_native_select(),
shad_radio_group(),
shad_select(),
shad_slider(),
shad_switch(),
shad_textarea(),
shad_toggle(),
shad_toggle_group()
Examples
shad_input_otp("code", length = 6, groups = c(3, 3))
#> <div class="shad-otp" data-shad="input-otp" id="code" data-length="6" data-pattern="\d">
#> <input class="shad-otp__input" type="text" inputmode="numeric" autocomplete="one-time-code" aria-label="One-time code"/>
#> <div class="shad-otp__group">
#> <div class="shad-otp__cell" aria-hidden="true"></div>
#> <div class="shad-otp__cell" aria-hidden="true"></div>
#> <div class="shad-otp__cell" aria-hidden="true"></div>
#> </div>
#> <div class="shad-otp__separator" aria-hidden="true"><svg class="shad-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M5 12h14"/></svg></div>
#> <div class="shad-otp__group">
#> <div class="shad-otp__cell" aria-hidden="true"></div>
#> <div class="shad-otp__cell" aria-hidden="true"></div>
#> <div class="shad-otp__cell" aria-hidden="true"></div>
#> </div>
#> </div>