Two factor and sign in
Verify screen
The second step after the password: masked destination, code cells that submit when complete, a resend link with a countdown, another method link and a "Don't ask again on this device for 30 days" checkbox. Needs monsoon.js for the cells and the countdown.
Needs monsoon.js. The styles work on their own, and the behavior comes from the optional interactive layer: add <script src="https://cdn.jsdelivr.net/npm/monsooncss/dist/monsoon.js" defer></script> or import 'monsooncss/js'. See the interactive layer.
Example
<form class="auth-card" action="#" onsubmit="event.preventDefault()">
<header class="auth-header">
<span class="auth-icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4.5 5.5h15a1 1 0 0 1 1 1V16a1 1 0 0 1-1 1H9l-4.5 3.5V6.5a1 1 0 0 1 1-1z"/><path d="M8.5 11.25h.01M12 11.25h.01M15.5 11.25h.01" stroke-width="2.4"/></svg></span>
<h2 class="auth-title">Enter the code we texted you</h2>
<p class="auth-description">We sent a 6 digit code to <span class="auth-destination">+55 •• •••••-0474</span>. It expires in 10 minutes.</p>
</header>
<div class="otp mx-auto" data-m-otp data-m-otp-separator="3" data-m-otp-autosubmit>
<input class="otp-field" name="code" maxlength="6" inputmode="numeric" autocomplete="one-time-code" aria-label="Verification code">
</div>
<label class="flex items-start gap-2.5 text-sm">
<input type="checkbox" class="checkbox checkbox-sm mt-0.5" name="trust_device" checked>
<span>Don't ask again on this device for 30 days</span>
</label>
<button class="btn btn-primary btn-block">Verify</button>
<div class="auth-alt">
<span>Didn't get it? <button type="button" class="link link-primary" data-m-auth-resend data-m-auth-resend-seconds="30">Resend code</button></span>
<a class="link link-muted" href="#methods">Try another method</a>
</div>
</form>JavaScript API
Attribute
data-m-auth-resend
Options
| Option | Description |
|---|---|
data-m-auth-resend-seconds="30" | |
data-m-auth-resend-idle (starts enabled, counts after the first click) | |
data-m-auth-resend-done="You can request a new code now." (announced at zero) |
Methods
| Method | Description |
|---|---|
Monsoon.authResend(el).remaining | |
Monsoon.authResend(el).start(60) | |
Monsoon.authResend(el).stop() |
Events
| Event | Description |
|---|---|
monsoon:auth-resend { seconds } (cancelable: preventDefault() keeps it enabled) | |
monsoon:auth-resend-ready | |
monsoon:otp-complete { code } |
Classes
8 classes. Click a name to copy it. Utilities on the same element always win over component defaults, so any of them can be adjusted with plain utility classes.
| Class | Type | What it does |
|---|---|---|
| Part | Part of the verify screen. On a <form> in the example. Sets grid display, gap, width, padding, text color and background, and 4 custom properties.CSS |
|
| Part | Part of the verify screen. On a <header> in the example. Sets grid display, alignment, gap and text style.CSS |
|
| Part | Part of the verify screen. On a <span> in the example. Sets grid display, alignment, width, height, margin and text color, and --tone.CSS |
|
| Part | Part of the verify screen. On a <h2> in the example. Sets margin, text size, font weight and text style.CSS |
|
| Part | Part of the verify screen. On a <p> in the example. Sets width, margin, text size, text style and text color.CSS |
|
| Part | Part of the verify screen. On a <span> in the example. Sets font weight, text color and text style.CSS |
|
| Base | Base class of the verify screen. On a <div> in the example. Sets flex display, alignment, gap, margin, text size and text color.CSS |
|
| Part | Part of the verify screen. Not used in the example above. Sets margin.CSS |
Usage
The styles ship inside the same stylesheet as the utilities, and the behavior comes from the optional monsoon.js script, which enhances any element with a matching data-m attribute, including markup added later.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/monsooncss">
<script src="https://cdn.jsdelivr.net/npm/monsooncss/dist/monsoon.js" defer></script>
<!-- Verify screen: start from the base class, then add modifiers -->
<form class="auth-card" action="#" onsubmit="event.preventDefault()">
<header class="auth-header">
<span class="auth-icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M4.5 5.5h15a1 1 0 0 1 1 1V16a1 1 0 0 1-1 1H9l-4.5 3.5V6.5a1 1 0 0 1 1-1z"/><path d="M8.5 11.25h.01M12 11.25h.01M15.5 11.25h.01" stroke-width="2.4"/></svg></span>
<h2 class="auth-title">Enter the code we texted you</h2>
<p class="auth-description">We sent a 6 digit code to <span class="auth-destination">+55 •• •••••-0474</span>. It expires in 10 minutes.</p>
</header>
<div class="otp mx-auto" data-m-otp data-m-otp-separator="3" data-m-otp-autosubmit>
<input class="otp-field" name="code" maxlength="6" inputmode="numeric" autocomplete="one-time-code" aria-label="Verification code">
</div>
<label class="flex items-start gap-2.5 text-sm">
<input type="checkbox" class="checkbox checkbox-sm mt-0.5" name="trust_device" checked>
<span>Don't ask again on this device for 30 days</span>
</label>
<button class="btn btn-primary btn-block">Verify</button>
<!-- the full example is in the Code tab above -->Theme it with --seed on any ancestor, for example style="--seed: #0d9488", and force a scheme with class="dark" or class="light" on a wrapper.
Accessibility
- Give every control a visible
labellinked withfor, or anaria-labelwhen the purpose is obvious from context. Link help and error text witharia-describedby; invalid styles use:user-invalid, so they appear only after the user interacts. - Checkboxes and radios stay real inputs, so they keep native keyboard behavior (Space toggles, arrow keys move within a radio group) and form submission.
- Use
buttonfor actions andafor navigation. Icon only buttons need anaria-label; decorative icons carryaria-hidden="true". - Every interactive part shows a visible focus ring with
:focus-visible, and tone colors pair with-foregroundtokens that keep text at 4.5:1 or better in light and dark mode.