Nested Form

Demonstrates how to mirror a nested data model in form config using section with nested: true and defineConfig for typed config fragments.

Preview & Code

Preview
Code
Full Name *
Email *
Street *
City *
Country *

How it works

section with nested: true — the address key becomes a namespace in the form state. Submitted data reflects the model shape:

{
  fullName: "Jane Doe",
  email: "jane@example.com",
  address: {
    street: "123 Main St",
    city: "Hanoi",
    country: "Vietnam",
  }
}

defineConfig<AddressData> — explicitly scopes the config fragment to AddressData, giving TypeScript full visibility into field keys and types within the section. Without it, TypeScript cannot infer the nested model shape from Form<ProfileData> alone.

Separation of concernsaddressConfig is defined outside the form and can be imported and reused in any other form that has an address field of the same shape.

Tip

If you prefer not to use section, dot notation keys are an alternative — "address.street" maps directly to the nested path with no extra setup. Use section when you want the config structure to mirror the data model.