Two factor and sign in
Sign in, compact
A compact card for popovers, sidebars and embedded flows: the method switcher and code entry in a tight layout with .auth-card-compact. Needs monsoon.js for the code cells.
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 auth-card-compact" action="#" onsubmit="event.preventDefault()">
<header class="auth-header auth-header-start">
<h2 class="auth-title text-lg">Confirm it's you</h2>
<p class="auth-description text-sm">Enter a code from your authenticator app to change your email.</p>
</header>
<div class="otp otp-sm" data-m-otp data-m-otp-separator="3">
<input class="otp-field" name="code" maxlength="6" inputmode="numeric" autocomplete="one-time-code" aria-label="Verification code">
</div>
<div class="flex items-center justify-between gap-2">
<a class="link link-muted text-sm" href="#recovery">Use a recovery code</a>
<button class="btn btn-primary btn-sm">Confirm</button>
</div>
</form>Classes
3 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 |
|---|---|---|
| Modifier | Modifier, combined with the auth-card class. On a <form> in the example. Sets gap, width and shadow, and --auth-pad and --auth-radius.CSS |
|
| Base | Base class of the sign in, compact. 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 sign in, compact. On a <header> in the example. Sets alignment, text style and width.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>
<!-- Sign in, compact: start from the base class, then add modifiers -->
<form class="auth-card auth-card-compact" action="#" onsubmit="event.preventDefault()">
<header class="auth-header auth-header-start">
<h2 class="auth-title text-lg">Confirm it's you</h2>
<p class="auth-description text-sm">Enter a code from your authenticator app to change your email.</p>
</header>
<div class="otp otp-sm" data-m-otp data-m-otp-separator="3">
<input class="otp-field" name="code" maxlength="6" inputmode="numeric" autocomplete="one-time-code" aria-label="Verification code">
</div>
<div class="flex items-center justify-between gap-2">
<a class="link link-muted text-sm" href="#recovery">Use a recovery code</a>
<button class="btn btn-primary btn-sm">Confirm</button>
</div>
</form>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. - 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.