Form

Typed signal-based form store (createForm/useForm) with sync/async validation and a thin Form element wrapper

Category: inputs · WCAG 2.2-AA · form, validation, signals, input

States

Props

PropTypeDefaultDescription
formFormStore<T>The form store holding values, validation, and submission state.
onValid(values: T) => void | Promise<void>Called with the values when the form passes validation.
childrenReactNodeContent rendered inside the component.
classNamestringAdditional CSS class names merged onto the root element.

Design tokens

When to use

When not to use

How to build an accessible Form in React →

Examples

Basic form with validation

function Demo() {
  const form = useForm({
    initialValues: { email: '' },
    validate: (v) => v.email.includes('@') ? {} : { email: 'Invalid email' },
  })
  const email = form.field('email')
  return (
    <Form form={form} onValid={console.log}>
      <Input
        label="Email"
        value={email.value}
        onChange={(e) => email.onChange(e.currentTarget.value)}
        onBlur={email.onBlur}
        error={email.error}
      />
      <Button type="submit">Save</Button>
    </Form>
  )
}

Related components

← Back to docs