Rokkit 1.0.3

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...

Custom Renderers

Replace any built-in control by passing a custom component via the renderers prop. Each entry maps a key to a Svelte component. Reference it in the layout element's props.renderer:

svelte
Highlighting code...

Any custom renderer receives bind:value, onchange, disabled, and all props defined in the layout element's props object. Built-in keys like toggle, switch, swatch are already registered — pass your own key to add new ones or override existing ones.

Use caserenderer keyReplaces
Color / pattern swatchswatchselect
Segmented toggletoggleselect / radio
Boolean switchswitchcheckbox
Any custom componentyour keyany built-in

Related