Form
Bind schema fields, validation, submission, and reset through createForm.
Use createForm for schema validation, submission, and reset. It returns a reactive Formisch store
with bound form.Form and form.Field components. Use standalone Field
when you only need labels and messages.
Basic usage#
Playground#
The slot controls below apply only to the form.Form root. To explore label, description,
help, and error slots, use the Field playground.
Anatomy#
Each form.Field uses the Field layout; the bound form.Form owns only its native form root.
Usage#
Basic form and submission#
Define a schema and initial input, then render the bound components returned by createForm.
form.Form prevents native navigation, validates the schema, and calls onSubmit with the
validated output. Native action and method attributes do not enable a browser navigation submit.
The returned store also supports Formisch’s public methods and helpers, including programmatic field focus.
Root styling#
<form.Form> owns only its native form root. Use direct class and style props for an individual form, or configure form.base.root in your Theme. Slot maps remain available on form.Field, but the bound Form component does not accept classes or styles.
Bound field outside the form root#
form.Field captures the Formisch store from createForm(), so it can be used without rendering form.Form. Use the standalone Field when schema binding is not needed.
Field labels and messages#
Configure label, hint, description, help, and required indicators on <form.Field>. Supported Moraine controls automatically link with helper descriptions and error messages via deterministic ARIA attributes.
Horizontal layout#
Set orientation="horizontal" to switch from the default stacked layout to a side-by-side grid arrangement, common in settings panels and administrative consoles.
Nested and array paths#
Target nested object and array fields by supplying path tuples (for example, ['profile', 'email']) to the name prop. Path types are fully validated and autocompleted based on your schema.
Submission and loading state#
form.Form does not automatically disable child controls during submission. Read form.isSubmitting to derive button loading spinners or disabled states while async form submissions are in flight.
Reset and state restoration#
Coordinate native reset events with Formisch: clicking a type="reset" button restores the initial store input snapshot and clears validation metadata.
Examples#
Schema validation#
Formisch validates fields according to schema rules and updates errors in real-time or upon submission, linking error messages directly to the associated controls.
Manual and server errors#
Pass application or server-returned error strings directly to <form.Field error={...}> to force an error state or display external validation messages.
Render context#
Provide a render function as child to <form.Field> to access the current effective { error } while the child control continues to inherit the bound field state.
Mixed form controls#
Compose multiple Moraine controls—such as Input, Textarea, Select, and Checkbox—within a single schema-validated form.
Attributes#
data-submittingSlot: formDescription: Present while the form is being submitted.Props#
Form#
Renders a <form> element by default.