Login card
A centered sign-in card with email, password, a remember-me option and links to reset the password or sign up.
Installation
Usage
Place the section where your sign-in page content goes. Point the form's action at your login handler and the two links at your password reset and sign-up pages.
The inputs use autocomplete="email" and autocomplete="current-password", so password managers fill them.
Accessibility
- Every input has a visible
<label>; required fields userequired. - The card heading names the section (
aria-labelledby). Change the heading level to fit your page; a sign-in page usually has it as its<h1>. - Show server errors next to the field: add
aria-invalid="true"and aninvalid-feedbackelement referenced witharia-describedby(see the Input component).
Dependencies
- Bootstrap 5.3+ CSS.
themes/tokens/tokens.css.- The
cardcomponent. - The
inputcomponent. - The
checkboxcomponent. - The
buttoncomponent.
Source
The exact files the CLI installs (login-card@1.0.0). View on GitHub · Report an issue
html
<section class="bootcn-login-card" aria-labelledby="bootcn-login-card-title">
<div class="card bootcn-card">
<header class="bootcn-card__header">
<h2 class="bootcn-card__title" id="bootcn-login-card-title">Sign in to your account</h2>
<p class="bootcn-card__description">Enter your email and password to continue.</p>
</header>
<form class="bootcn-card__content bootcn-login-card__form" action="#" method="post">
<div class="bootcn-field">
<label for="bootcn-login-card-email" class="form-label bootcn-field__label">Email</label>
<input
type="email"
class="form-control bootcn-input"
id="bootcn-login-card-email"
name="email"
autocomplete="email"
placeholder="you@example.com"
required
/>
</div>
<div class="bootcn-field">
<div class="bootcn-login-card__label-row">
<label for="bootcn-login-card-password" class="form-label bootcn-field__label"
>Password</label
>
<a class="bootcn-login-card__link" href="#forgot-password">Forgot password?</a>
</div>
<input
type="password"
class="form-control bootcn-input"
id="bootcn-login-card-password"
name="password"
autocomplete="current-password"
required
/>
</div>
<div class="form-check bootcn-checkbox">
<input
class="form-check-input bootcn-checkbox__input"
type="checkbox"
id="bootcn-login-card-remember"
name="remember"
/>
<label class="form-check-label bootcn-checkbox__label" for="bootcn-login-card-remember"
>Keep me signed in</label
>
</div>
<button type="submit" class="btn bootcn-button bootcn-button--default w-100">Sign in</button>
</form>
<footer class="bootcn-card__footer bootcn-login-card__footer">
<p class="mb-0">
No account yet? <a class="bootcn-login-card__link" href="#sign-up">Create one</a>
</p>
</footer>
</div>
</section>css
.bootcn-login-card {
width: 100%;
max-width: 24rem;
margin-inline: auto;
}
.bootcn-login-card__form {
display: flex;
flex-direction: column;
gap: 1rem;
}
.bootcn-login-card__form .bootcn-field {
margin: 0;
}
.bootcn-login-card__label-row {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 1rem;
}
.bootcn-login-card__link {
color: var(--bs-link-color);
font-size: 0.875rem;
text-underline-offset: 0.2em;
}
.bootcn-login-card__footer {
justify-content: center;
font-size: 0.875rem;
color: var(--bs-secondary-color);
}
