Generative form

A form the agent builds mid-conversation to collect exactly what it still needs, instead of asking one question at a time.

Loading preview…

Install

  1. 1

    Run this command in your Tailwind CSS project. It adds components/ai/generative-form-inline.tsx and installs its dependencies.

    $ npx shadcn@latest add https://gradientdeck.com/ai-components/r/generative-form-inline.json

Usage & API

Example

generative-form-inline.tsx
import { GenerativeForm } from "@/components/ai/generative-form-inline"

<GenerativeForm
  title="…"
  fields={[]}
  values={values}
  onChange={() => {}}
  status="open"
  onSubmit={() => {}}
  onReopen={() => {}}
/>

Props GenerativeForm

PropType & descriptionRequired
titlestringRequired
fieldsFormField[]Required
valuesFormValuesRequired
onChange(id: string, value: FieldValue) => voidRequired
inferredRecord<string, { value: FieldValue; source: string }>Values the agent filled in itself, with where they came from. A field keeps its note while its value is unchanged.Optional
status"open" | "sending" | "sent"Required
onSubmit() => voidRequired
onReopen() => voidRequired
submitLabelstringOptional

Dependencies

  • React
  • Tailwind CSS
  • motion
  • lucide-react
Implementation notes

The inline card is titled by you and stacks every field. The date field opens a month grid with previous and next month, and busy days can show a dot. The count field has fewer and more buttons and shows its unit. Money has an amount and a currency menu. Select, chips and text use the placeholders you set. An inferred value keeps a note naming its source until it is edited. The footer submits with the label you pass, and mentions Ctrl and Enter. While status is sending, the button waits. Once sent, the answers are summarized and can be reopened.

Choosing a layout

Use it when the agent has stopped because it is missing a structured set of facts, and a free-text reply would just make it ask again. Dates, headcount, budget, a venue and a few tags are the kind of set the field types cover. Use steps when that set is long enough that one card is a wall. Use the inline card when five or six fields fit in the reply.

If the agent already drafted the action and the person only needs to correct a recipient or an argument, edit before run is the closer tool. If the pause is a yes or no on a side effect, the decision inbox is the closer one. A generative form collects values. It does not approve a tool call.

Does the form decide which questions to ask?

No. You pass the title, the fields and, for the stepped variant, which field ids sit on which step. Inferred values are also yours: a value plus the source line that should appear under the field until the person edits it.

What does the person get back after sending?

Status moves to sending, then sent. The card replaces the editors with the formatted answers, and onReopen returns it to open. The date is shown as a short weekday and day, money with its symbol, and the other kinds as the label or the text that was chosen.