Form controls and validation
Native form fields provide familiar keyboard behavior. Alpine binds local input state while your backend performs authoritative validation.
Start with your first page. Shared ui* providers are registered by createAdmin. Examples belong inside a route template, not the root HTML document. The page and its optional controller load through Ātrium’s lazy route registry.
Minimal example
<label class="form-label" for="display-name">Display name</label><input id="display-name" class="form-control" x-model="form.name" required /><label class="form-check form-switch"> <input class="form-check-input" type="checkbox" role="switch" x-model="form.enabled" /> <span>Enabled</span></label>Settings and behavior
- Define form.name and form.enabled in your page provider.
- Supported examples cover text, email, password, URL, phone, search, number, date, time, datetime, textarea, select, multiple select, file, color, range, radio, checkbox, and switch controls.
- Use form-control-sm or form-control-lg for sizes, input-group for joined controls, and form-floating for floating labels.
- Single-line fields and selects match button heights at 40 pixels by default, 32 pixels for small controls, and 48 pixels for large controls. Use matching size modifiers for adjacent controls. Floating labels, textareas, and multiple selects retain the height needed for their content.
- Place adjacent fields, prefix or suffix text, and action buttons inside one
input-group. The shared theme preserves Bootstrap’s joined inner corners in both text directions, including sized groups and validation feedback. - Use a named icon button for password visibility, with a translated accessible label and pressed state. The showcase uses the built-in
eyeandeyeOfficons while preserving the entered value. - Place a floating label after its input and provide a nonempty
placeholderattribute. The placeholder stays visually hidden while the label moves above the value on focus or when filled. - Wrap repeated radio choices in a container immediately after the fieldset legend so the rendered choices clear the legend, even when an Alpine template generates them.
- Native file-picker buttons fill the control’s inner height in default, small, and large sizes.
- Text fields, textareas, and selects show focus by changing their existing border to the accent color, without an additional outline or shadow.
- Connect validation text using aria-describedby and set aria-invalid when invalid.
- Apply indeterminate checkbox state in a provider method. The CSP runtime rejects DOM assignments inside markup.
Integration notes
The forms controller demonstrates submission, busy state, validation messages, and focusing the first invalid field. File examples show names only. Uploading requires your own adapter. Never store password fields in preferences.
Working reference
See the production example. Return to the component index.
Author
Laurent Declercq l.declercq@agon-innovation.ch
License
Unless otherwise stated all source code is licensed under LGPL 2.1 and has the following copyright:
© 2026, Agon Partners Innovation AG, All rights reserved.The design material and the “Agon Ātrium” trademark is the property of their authors. Reuse of them without prior consent of their respective authors is strictly prohibited.
Version
Version: 20260923