Verify with a code
A second-step card that asks for the six-digit code sent by SMS or email, with resend.
Installation
Usage
Show it after the password step. The code field is the Input OTP component: the phone's SMS suggestion and paste fill all six digits, and its bootcn:otp:complete event can submit the form automatically. Rate-limit "Send a new code" on the server.
Accessibility
- One labelled input holds the code (
autocomplete="one-time-code"); the boxes are visual only. - The description says where the code went, without revealing the full number.
Dependencies
- Bootstrap 5.3+ CSS.
themes/tokens/tokens.css.- The
cardcomponent. - The
input-otpcomponent. - The
buttoncomponent. - The
labelcomponent.
Source
The exact files the CLI installs (login-otp@1.0.0). View on GitHub · Report an issue
html
<section class="bootcn-login-otp" aria-labelledby="bootcn-login-otp-title">
<div class="card bootcn-card">
<header class="bootcn-card__header bootcn-login-otp__header">
<h2 class="bootcn-card__title" id="bootcn-login-otp-title">Enter verification code</h2>
<p class="bootcn-card__description">We sent a 6-digit code to your phone ending in 214.</p>
</header>
<form class="bootcn-card__content bootcn-login-otp__form" action="#" method="post">
<div class="bootcn-field bootcn-login-otp__field">
<label class="bootcn-label" for="bootcn-login-otp-code">Verification code</label>
<div class="bootcn-otp" data-bootcn-otp>
<input
class="bootcn-otp__input"
id="bootcn-login-otp-code"
name="code"
type="text"
inputmode="numeric"
autocomplete="one-time-code"
pattern="[0-9]*"
maxlength="6"
required
/>
<div class="bootcn-otp__slots" aria-hidden="true">
<div class="bootcn-otp__group">
<span class="bootcn-otp__slot"></span>
<span class="bootcn-otp__slot"></span>
<span class="bootcn-otp__slot"></span>
</div>
<span class="bootcn-otp__separator">–</span>
<div class="bootcn-otp__group">
<span class="bootcn-otp__slot"></span>
<span class="bootcn-otp__slot"></span>
<span class="bootcn-otp__slot"></span>
</div>
</div>
</div>
</div>
<button type="submit" class="btn bootcn-button bootcn-button--default w-100">Verify</button>
<p class="bootcn-login-otp__resend">
Didn’t get it?
<button type="button" class="btn bootcn-button bootcn-button--link bootcn-button--sm">
Send a new code
</button>
</p>
</form>
</div>
</section>css
.bootcn-login-otp {
width: 100%;
max-width: 22rem;
margin-inline: auto;
}
.bootcn-login-otp__header {
align-items: center;
text-align: center;
}
.bootcn-login-otp__body,
.bootcn-login-otp__form {
display: flex;
flex-direction: column;
gap: 1rem;
}
.bootcn-login-otp__form .bootcn-field {
margin: 0;
}
.bootcn-login-otp__label-row {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 1rem;
}
.bootcn-login-otp__link {
color: var(--bs-link-color);
font-size: 0.875rem;
text-underline-offset: 0.2em;
}
.bootcn-login-otp__footer {
justify-content: center;
color: var(--bootcn-muted-foreground);
font-size: 0.875rem;
}
.bootcn-login-otp__field {
align-items: center;
}
.bootcn-login-otp__resend {
margin: 0;
color: var(--bootcn-muted-foreground);
font-size: 0.875rem;
text-align: center;
}
.bootcn-login-otp__resend .bootcn-button {
min-height: 0;
padding: 0;
vertical-align: baseline;
}
