Form
An unstyled form coordinating field validation, versioned async submission, implicit Enter submit, and form reset.
Base Form gathers explicitly registered FormField controls, validates all enabled fields, and emits form values keyed by field name on submit, while coordinating async validation lifetimes and reset actions.
Preview
Section titled “Preview”Versioned async validation and nested groups
Section titled “Versioned async validation and nested groups”Demonstrates resolving external validation requests by requestId via resolveValidation, canceling or superseding in-flight submissions, and coordinating nested Fieldset disabled groups with form reset.
Explicit choice fields
Section titled “Explicit choice fields”Import fieldCheckbox, fieldRadioGroup, and fieldSwitch from @proto.ui/prototypes-base/field inside a FormField to integrate checkboxes, radio groups, and switches with required validation, read-only/disabled policy, and reset.
Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases. In the workspace, the CLI target is base-form.
Anatomy
Section titled “Anatomy”Compose Root, Field, Submit, and Reset:
Root: collects uniquely named enabledFieldcontrols and emits form values keyed by field name onsubmitonce validation passes. Disabled fields (including those inside a disabledFieldset) are omitted, and duplicate names ignore invalid serialization.Field: registers a named control for validation, serialization, and reset.Submit/Reset: handle pointer and keyboard activation and exposedisabled,hovered,pressed,focused,focusVisible, andfocusSelf().
Implicit submit, async validation, and reset
Section titled “Implicit submit, async validation, and reset”- Pressing
Enterinside a focused single-lineField,Number Field, orInput OTPtriggers form submission (excluding IME composition, modifier keys, and repeated keydown events). - Async validation awaits current results and automatically discards stale replies after edits, unmounts, cancellations, or newer submit attempts.
requestReset()restores uncontrolled initial values, requests initial values from controlled owners, cancels pending validation, and emitsreset.resetValidation()clears validation state only.
Root Props
Section titled “Root Props”| Prop | Type | Default |
|---|---|---|
disabled | boolean | false |
ariaLabel | string | '' |
Other parts
Section titled “Other parts”- Field:
namedefaults to''. - Submit, Reset:
disableddefaults tofalse.