Form Builder
ProNewA schema-driven form with text, number, URL, date/time, choices, file and rating inputs plus headings and explanatory text. Render inline, in a side panel or in a popup, with validation, steps and a success screen.
Installation
First time? Add the @viewport registry to components.json. Setup takes one minute.
Usage
Props
<FormBuilder>
| Prop | Type | Default |
|---|---|---|
| title | string | — |
| description | string | — |
| steps* | FormStep[]The schema. One step renders a plain form; more add the progress header and Back and Next. | — |
| layout | "inline" | "pane" | "popup"`inline` renders in place; `pane` opens a side panel and `popup` a centered dialog from a trigger button. | "inline" |
| fieldStyle | "filled" | "outlined"Look of the inputs. | "filled" |
| labelStyle | "above" | "hidden"`above` shows labels over the fields; `hidden` keeps them for screen readers and relies on placeholders. | "above" |
| onSubmit | (values: FormValues) => void | Promise<void>Called with the values once every step is valid. Return a promise to show the pending state; reject it to show the error. | — |
| accent | stringAccent for the buttons, focus and selected choices. Any CSS color. | "var(--primary)" |
| accentForeground | stringText color on top of the accent. | "var(--primary-foreground)" |
| triggerLabel | stringText of the trigger for the `pane` and `popup` layouts. | "Leave feedback" |
| triggerClassName | stringClass for that trigger, e.g. to reposition it. | — |
| disabled | booleanDisable every field and the buttons. | — |
| labels | Partial<typeof LABELS>Override any of the built-in strings. | — |
| className | string | — |
<Form>
| Prop | Type | Default |
|---|---|---|
| text* | Labels | — |
| title* | React.ReactNode | — |
| onClose | () => void | — |
<FieldView>
| Prop | Type | Default |
|---|---|---|
| field* | FormField | — |
| value* | FormValue | — |
| error | string | — |
| onChange* | (value: FormValue) => void | — |
| disabled | boolean | — |
| id* | string | — |
| filled* | boolean | — |
| hideLabel* | boolean | — |
| text* | Labels | — |
Accessibility
- Every input has a real label or legend; choices, scales, smileys and stars are native radio groups driven by the arrow keys.
- Invalid fields get aria-invalid and a linked message, the first one takes focus, and a summary is announced as an alert.
- Display-only headings and paragraphs are not submitted or validated; HTTP(S) and numeric bounds have clear error messages.
- Steps report their position through a progress bar, and focus moves to the new step or the success screen.
- The file field works by keyboard, by browsing and by drag and drop; each file has a named remove button.
- The side panel and popup trap focus and return it to the trigger. Steps do not slide and the check mark does not draw under reduced motion.