Rokkit 1.0.0-next.128

Forms

Schema-driven forms with validation, lookups, and field dependencies

Rokkit Forms let you build complex forms from a JSON schema. Define fields, validation rules, and dependencies declaratively — the form builder handles rendering, validation, dirty tracking, and dynamic lookups.

Schema-Driven Forms

Define your form as a schema with typed properties. If you skip the schema, Rokkit auto-derives one from your data:

svelte
Highlighting code...

Auto-Derived Schema

Pass just data — Rokkit infers the schema and layout automatically:

svelte
Highlighting code...

Validation

Add validation rules directly in the schema. Built-in validators handle common patterns:

RuleApplies ToExample
requiredAll typesrequired: true
min / maxNumbersmin: 18, max: 120
minLength / maxLengthStringsminLength: 8
patternStringspattern: '^[A-Z]'
formatStringsformat: 'email'
enumStringsenum: ['a', 'b']

Control when validation triggers with the validateOn prop:

svelte
Highlighting code...

Add custom validation logic with the onvalidate callback:

svelte
Highlighting code...

Lookups

Populate select fields dynamically using lookups. Three patterns are supported:

svelte
Highlighting code...

Field Dependencies

When a lookup declares dependsOn, changing the dependency field automatically clears the dependent field's value and re-fetches its options. Fields with unmet dependencies are disabled until all required values are set.

javascript
Highlighting code...

FormBuilder

For programmatic control, use FormBuilder directly:

svelte
Highlighting code...

Custom Actions

Override the default Submit/Reset buttons with a custom actions snippet:

svelte
Highlighting code...

Related