Login block
Email and password sign-in form with validation messages.
SourceStyles source@monoline/react 0.4.0Markdown for AI toolsbeta
- Built on native elements
- A section named by its title; the form is named by the same heading.
- Invalid submits show a role=alert summary whose links move focus to each field, and each field gets aria-invalid and an error message.
- Email and password carry autocomplete hints for password managers.
- Styles in one file:
form.css
Import
import '@monoline/css';
import {BlockLogin} from '@monoline/react';
Not installed yet? Pick a route.
Copies the source and its styles into your project.
npx monoline add block-login
Usage
import {BlockLogin, Link} from '@monoline/react';
<BlockLogin
description="Use the email you signed up with."
footer={<><Link href="#">Forgot your password?</Link><Link href="#">Create an account</Link></>}
/>
Examples
Props
BlockLoginProps
| Prop | Type | Default | Description |
|---|---|---|---|
title | ReactNode | 'Sign in' | Heading of the form. Default "Sign in". |
description | ReactNode | – | Optional muted line under the heading. |
submitLabel | ReactNode | 'Sign in' | Text of the submit button. Default "Sign in". |
onSubmit | ((values: LoginValues) => void) | – | Called with the values once they pass validation. |
loading | boolean | – | Shows a spinner on the submit button while you sign in. |
footer | ReactNode | – | Links under the form: forgot password, create an account. |
messages | Partial<{ email: string; emailInvalid: string; password: string; }> | – | Replace the validation messages (translate them, or change the tone). |
headingLevel | 1 | 2 | 3 | 1 | Outline level of the title, 1 to 3. Default 1 because a login page is usually the page's h1. |
Data Attributes
State is exposed through attributes. Style it with these selectors, not with class toggles.
| Attribute | Stylesheet |
|---|---|
[aria-checked="true"] | 03-form-fields.css |
[aria-invalid="true"] | 03-form-fields.css |
[aria-pressed="true"] | 03-form-fields.css |
[data-valid="true"] | 11-field-states.css |
CSS classes
| Class | Stylesheet |
|---|---|
.form | form.css |
.form-actions | form.css |
.form-errors | form.css |
.form-errors-title | form.css |
.field | 03-form-fields.css |
.field-hint | 03-form-fields.css |
.input | 03-form-fields.css |
.input-bare | 03-form-fields.css |
.input-end | 03-form-fields.css |
.input-lg | 03-form-fields.css |
.input-sm | 03-form-fields.css |
.input-wrap | 03-form-fields.css |
.muted | 03-form-fields.css |
.seg | 03-form-fields.css |
.seg-opt | 03-form-fields.css |
.select | 03-form-fields.css |
.setting | 03-form-fields.css |
.switch | 03-form-fields.css |
.textarea | 03-form-fields.css |
.field-error | 11-field-states.css |
.field-ok | 11-field-states.css |
.field-required | 11-field-states.css |
.form-row | 11-field-states.css |
.input | 11-field-states.css |
.input-affix | 11-field-states.css |
.input-group | 11-field-states.css |
.select | 11-field-states.css |
.textarea | 11-field-states.css |
.btn | 02-buttons.css |
.btn-block | 02-buttons.css |
.btn-danger | 02-buttons.css |
.btn-ghost | 02-buttons.css |
.btn-lg | 02-buttons.css |
.btn-line | 02-buttons.css |
.btn-sm | 02-buttons.css |
.btn-solid | 02-buttons.css |
.skeleton | 13-loading.css |
.skeleton-block | 13-loading.css |
.skeleton-hatch | 13-loading.css |
.spinner | 13-loading.css |
.heading | heading.css |
.heading-display | heading.css |
.heading-lg | heading.css |
.heading-md | heading.css |
.heading-sm | heading.css |
.heading-xl | heading.css |
.text | text.css |
.text-accent | text.css |
.text-danger | text.css |
.text-full | text.css |
.text-lg | text.css |
.text-md | text.css |
.text-muted | text.css |
.text-ok | text.css |
.text-sm | text.css |
.text-success | text.css |
.text-truncate | text.css |
.text-warning | text.css |
.text-xs | text.css |
.block-login | block-login.css |
.block-login-footer | block-login.css |
.block-login-head | block-login.css |
Customization
Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.
app.css
.form {
border-color: var(--accent);
}
.form[aria-checked="true"] {
background: var(--wash);
}
Accessibility
- A section named by its title; the form is named by the same heading.
- Invalid submits show a role=alert summary whose links move focus to each field, and each field gets aria-invalid and an error message.
- Email and password carry autocomplete hints for password managers.