Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Form Builder

ProNew

A 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

pnpm dlx shadcn@latest add @viewport/form-builder

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

<FormBuilder>

PropTypeDefault
titlestring—
descriptionstring—
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.

—
accentstring

Accent for the buttons, focus and selected choices. Any CSS color.

"var(--primary)"
accentForegroundstring

Text color on top of the accent.

"var(--primary-foreground)"
triggerLabelstring

Text of the trigger for the `pane` and `popup` layouts.

"Leave feedback"
triggerClassNamestring

Class for that trigger, e.g. to reposition it.

—
disabledboolean

Disable every field and the buttons.

—
labelsPartial<typeof LABELS>

Override any of the built-in strings.

—
classNamestring—

<Form>

PropTypeDefault
text*Labels—
title*React.ReactNode—
onClose() => void—

<FieldView>

PropTypeDefault
field*FormField—
value*FormValue—
errorstring—
onChange*(value: FormValue) => void—
disabledboolean—
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.