Form
Structured form layout with labels, descriptions, and validation messages.
Installation
dotnet add package Lumeo
One-time app setup (AddLumeo(), CSS & JS) is covered in the
installation guide.
Usage
@using Lumeo <Form />
When to Use
- Data collection forms such as registration, contact, or feedback forms
- Settings pages with multiple fields that need labels and validation
- Multi-field validation workflows like password changes or profile updates
- Any form requiring consistent layout with labels, descriptions, and error messages
Validation Pattern
Lumeo form inputs (Input, Select, Checkbox, Switch, Textarea, and others) do not carry
Label, Required, Error, or HelpText props directly.
Instead, wrap any input in <FormField> to attach a label, helper text, required marker, and inline error message.
The FormField cascades a FormFieldContext so that child <FormLabel> and <FormMessage>
components automatically reflect the error state without any extra wiring.
We will never share your email.
Receive updates about your account.
Examples
This is your public display name.
We will never share your email.
Enter your email address.
Please enter a valid email address.
Please enter a valid email address.
At least 8 characters.
Reset to initial values
The Form component takes a snapshot of the model when it's first attached. Two reset methods are available:
- Form.Reset() — clears errors, dirty fields, and submission state, but leaves the bound model values alone. Useful after a successful submit when you want to keep what the user typed but drop the validation overlay.
- Form.ResetValues() — restores every property on the model to the snapshot taken at first render, then clears errors / dirty / submission state. The "Cancel changes" button on an edit form.
Snapshot timing. The snapshot is captured on first render against the model reference you
passed. If you swap the entire model (e.g. _model = newOne),
call Form.CaptureSnapshot()
on the new model so the next ResetValues()
restores to the right baseline.
API Reference
Form<TModel>
| Prop | Type | Default | Description |
|---|---|---|---|
| Model | TModel? | null | The form model object to validate. |
| ChildContent | RenderFragment? | null | Form fields and submit button. |
| OnValidSubmit | EventCallback<TModel> | — | Callback invoked when the form is submitted and validation passes. |
| OnInvalidSubmit | EventCallback<TModel> | — | Callback invoked when the form is submitted and validation fails. |
| Validator | IFormValidator? | null | Custom validator implementation for the form model. |
| Class | string? | null | Additional CSS classes. |
| AdditionalAttributes | Dictionary<string, object>? | null | Additional HTML attributes. |
FormField
| Prop | Type | Default | Description |
|---|---|---|---|
| Label | string? | null | Label text for the field. |
| HelpText | string? | null | Helper text shown below the input when there is no error. |
| Error | string? | null | Error message. Turns the label red and displays below the input. |
| Required | bool | false | Shows a red asterisk next to the label. |
| Orientation | Lumeo.Orientation | Vertical | Layout orientation. Values: Vertical, Horizontal. |
| LabelWidth | string? | null | Width of the label column in horizontal orientation. |
| Name | string? | null | Field name identifier for validation. |
| ChildContent | RenderFragment? | null | Input elements for the field. |
| Class | string? | null | Additional CSS classes. |
| AdditionalAttributes | Dictionary<string, object>? | null | Additional HTML attributes. |
FormItem
| Prop | Type | Default | Description |
|---|---|---|---|
| ChildContent | RenderFragment? | null | Form item content (label, input, description, message). |
| Class | string? | null | Additional CSS classes. |
| AdditionalAttributes | Dictionary<string, object>? | null | Additional HTML attributes. |
FormLabel
| Prop | Type | Default | Description |
|---|---|---|---|
| ChildContent | RenderFragment? | null | Label text. Turns red when the parent FormField has an error. |
| Class | string? | null | Additional CSS classes. |
| AdditionalAttributes | Dictionary<string, object>? | null | Additional HTML attributes. |
FormDescription
| Prop | Type | Default | Description |
|---|---|---|---|
| ChildContent | RenderFragment? | null | Helper description text. |
| Class | string? | null | Additional CSS classes. |
| AdditionalAttributes | Dictionary<string, object>? | null | Additional HTML attributes. |
FormMessage
| Prop | Type | Default | Description |
|---|---|---|---|
| Class | string? | null | Additional CSS classes. |
| AdditionalAttributes | Dictionary<string, object>? | null | Additional HTML attributes. Automatically displays the error from the parent FormField. |