---
title: "Form"
description: "Validates on submit; Step children make a step form."
---

> Documentation Index
> Fetch the complete documentation index at: https://gistui.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Form

```gistui
root = Form("invite", Input("email", "Work email", type:email, required), Select("role", "Role", ["Viewer", "Editor", "Admin"], value:"Editor"), Checkbox("terms", "I accept the terms", required), submit:"Send invite", success:"Invite sent.")
```

Submit it empty to see validation. A valid submit reaches `onAction` with typed values and a JSON Schema.

## Signature

This is the line a model reads in the system prompt.

```gistui
Form(name, ...children, id:str, validate:submit|blur|change, success:str, submit:str, draft:str)
```

- **Group:** Forms
- **Children:** Yes: any component or text
- **Positional arguments:** `name` (a trailing `?` means it may be left out)

## Props

| Prop | Type | How to write it | Notes |
|---|---|---|---|
| `name` | string | positional, required |  |
| `id` | string | named: `id:…` | stable id your app routes on |
| `validate` | `submit` · `blur` · `change` | named: `validate:…` | Default `"submit"`. when fields are checked |
| `success` | string | named: `success:…` | message shown after a valid submit |
| `submit` | string | named: `submit:…` | submit label; added if no primary Button |
| `draft` | string | named: `draft:…` | partial-save button label |

## Use your own component

Keep the name and schema, swap what is drawn. The prompt and the model's output do not change.

### React

```tsx
import { ui } from "@gistui/react/ui";

const lib = ui.extend({ Form: MyForm });
<GistUI library={lib} stream={response.body} />;
```
### Vue

```vue
<GistUI :source="answer" :components="{ Form: MyForm }" />
```
### Svelte

```svelte
<GistUI source={answer} components={{ Form: MyForm }} />
```
### Solid

```tsx
<GistUI source={answer()} components={{ Form: MyForm }} />
```
### Vanilla

```ts
import { ui } from "@gistui/vanilla/ui";

const lib = ui.extend({ Form: (ctx) => ({ el: myElement(ctx) }) });
```

See [Custom components](/docs/guides/custom-components/) for the full contract. Style hook: `[data-gistui="Form"]`.

Source: https://gistui.com/docs/components/forms/form/index.mdx
