Sign-up block
Name, email and password account 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.
- The password hint states the minimum length; autocomplete hints are set.
- Styles in one file:
form.css
Import
import '@monoline/css';
import {BlockSignup} from '@monoline/react';
Not installed yet? Pick a route.
Copies the source and its styles into your project.
npx monoline add block-signup
Usage
import {BlockSignup, Link} from '@monoline/react';
<BlockSignup
description="It takes a minute."
footer={<span>Already have an account? <Link href="#">Sign in</Link></span>}
/>
Examples
Props
BlockSignupProps
| Prop | Type | Default | Description |
|---|---|---|---|
title | ReactNode | 'Create your account' | Heading of the form. Default "Create your account". |
description | ReactNode | – | Optional muted line under the heading. |
submitLabel | ReactNode | 'Create account' | Text of the submit button. Default "Create account". |
onSubmit | ((values: SignupValues) => 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<{ name: string; email: string; emailInvalid: string; password: string; passwordShort: string; }> | – | Replace the validation messages (translate them, or change the tone). |
passwordMin | number | 8 | Shortest password accepted. Default 8. |
headingLevel | 1 | 2 | 3 | 1 | Outline level of the title, 1 to 3. Default 1 because a signup 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-signup | block-signup.css |
.block-signup-footer | block-signup.css |
.block-signup-head | block-signup.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.
- The password hint states the minimum length; autocomplete hints are set.