Form Wire
API Reference

Components

Form, Wizard, Field, Fields, Step, When, Row

Form

Renders a <form> element with all visible fields auto-appended. Accepts all standard <form> HTML attributes except children and action.

<Contact.Form
  action={submitAction}
  mapper={customMapper}
  defaultValues={{ name: "Ada" }}
  validationTiming="onBlur"
  draftPersistence={{ key: "my-draft", adapter: localStorageAdapter() }}
  className="my-form"
/>

Props

PropTypeDescription
actionActionHandlerServer action (required)
mapperFormWireMapperOverride the provider mapper
defaultValuesDeepPartial<SchemaOutput>Initial values
validationTiming"onSubmit" | "onBlur" | "onChange"When to validate
draftPersistenceDraftPersistenceConfigAuto-save config

Wizard

Same props as Form, plus:

PropTypeDescription
nextLabelstringLabel for the Next button
previousLabelstringLabel for the Previous button
submitLabelstringLabel for the final Submit button
childrenReactNodeMust contain <Step> components

Field

Renders a single field by name.

<Contact.Field name="email" className="my-field" />

Override presentation state per-field:

<Contact.Field name="email" hidden={false} readOnly disabled />

Fields

Renders a list of named fields in order:

<Contact.Fields names={["name", "email"]} />

If names is omitted, renders all fields.

Step

Declares a wizard step:

<Wizard.Step title="Contact Info">
  <Wizard.Field name="email" />
</Wizard.Step>

When

Conditionally renders children:

<Contact.When field="type" equals="business">
  <Contact.Field name="company" />
</Contact.When>

// or with a predicate
<Contact.When matches={(values) => values.type === "business"}>
  <Contact.Field name="company" />
</Contact.When>

Row

Horizontal layout helper for fields:

import { Row } from "@form-wire/react";

<Row columns={2}>
  <Contact.Field name="firstName" />
  <Contact.Field name="lastName" />
</Row>

FormWireProvider

Provides a mapper and validation timing to a subtree:

<FormWireProvider mapper={htmlMapper} validationTiming="onBlur">
  {children}
</FormWireProvider>

On this page