Koala logo Design
Esc
No matches for “
↑↓ navigate open Esc close
Components Forms

Forms

Label above, input full width, validation below. FluentValidation on the server, no client-side validation. koala-inline-validation-for wires per-field validation on blur via Alpine-AJAX.

<koala-field>

Canonical

One <koala-field> tag replaces a four-line <label> + <input> + <span asp-validation-for> quadruple. Single column on every viewport.

Variants

5 variants
We'll send the quote here.
Input
Single-line text, email, tel, url, number.
Select a category
Select
Alpine dropdown with custom options.
Textarea
Multi-line input. Server-side max-length only.
Reject new builds
Switch
Binary on/off. koala-switch.
Yes
No
Radio card
Pill-style Yes / No via koala-radio-yes-no.

States

4 states
Default state.
Default
Focus ring matches primary.
Focus
Enter a valid email address
Error
Disabled, opacity 0.6.
Disabled

Props

7 attributes
Attribute Values Notes
forRazor model expressionRequired, binds to the input model property.
labelstringAbove the input. Auto-required suffix when the validator has NotEmpty().
typetext, email, tel, url, number, passwordHTML input type. Defaults to text.
koala-input-prefixEmail, PhoneLeading icon inside the input.
koala-inline-validation-forRazor model expressionWires per-field validation on blur via Alpine-AJAX.
koala-invalid-forRazor model expressionAdds the invalid border to a custom picker (button, div, etc.).
novalidateAlways on the form. FluentValidation is the sole validator.

Do & don't

We'll send the quote here.
Do Label above, input full width, helper or validation below. Single column on every viewport.
We'll send the quote here.
Don't Don't put the label on the side. Mobile collapses badly and screen readers stop announcing the relationship.

Working example

FluentValidation · server-side backed by FormsModel
£
Reset

Form actions

Bottom-of-form action button row. Stacks vertically on mobile, switches to horizontal on sm: and above. Replaces the flex flex-col sm:flex-row gap-3 wrapper that opens every form footer.

<koala-form-actions>

Form errors

Top-of-form danger banner that renders the model-level ModelState[string.Empty] errors. Renders nothing when the form is valid, so the spacing doesn't shift between states.

<koala-form-errors>

Mounted via <koala-form-errors />; the danger block above is a static visualisation because the design page has no failing ModelState to seed real errors from.