Form
Form coordinates related fields, submission, validation, and server errors in one accessible workflow.
Purpose
Form coordinates related fields, submission, validation, and server errors in one accessible workflow.
Submit flow
Installation
With the Siteplane registry alias configured, add the component and import the installed source from your app.
CLI
pnpm dlx shadcn@4.16.1 add @siteplane/formImport
import { Form } from "@/components/ui/form";
import { Field, FieldDescription, FieldError, FieldLabel } from "@/components/ui/field";Need the machine-readable source metadata? View registry JSON.
Usage
Use Form to wrap a submit flow. It connects field errors through names; use Field inside it for accessibility.
"use client";
import { Form } from "@/components/ui/form";
import { Field, FieldLabel } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
export function Example() {
return (
<Form onSubmit={(event) => event.preventDefault()}>
<Field name="email"><FieldLabel>Email</FieldLabel><Input /></Field>
<Button type="submit">Save</Button>
</Form>
);
}Examples
Validation, server errors, submission flows and layout patterns are compositions of the same primitive.
Required fields
Native required validation fills FieldError on submit.
Server errors
The errors prop maps server responses to fields by name. Submitting the handle "admin" is rejected.
Loading submit
Reset
Settings form
Inline form
API Reference
The reference lists the source-owned exports and props that are easy to miss in visual examples. Inherited Base UI props remain available unless the wrapper narrows them.
- Give every Field a stable
name. errorsacceptsRecord<string, string | string[]>; each key matches a Field name and renders through its FieldError.- Use the native
onSubmitflow and real submit and reset Button controls. - Group related sections with Fieldset and FieldsetLegend.
Motion
Component motion uses the shared Siteplane motion contract. See the global motion guide for provider setup, tokens and reduced-motion behavior.
- Form has no animation of its own.
- Controls and Buttons retain their native focus, loading, validation, and reduced-motion behavior.
- Reserve stable space or use concise feedback so validation does not move the entire workflow unexpectedly.
Accessibility
- Every control requires a connected FieldLabel or accessible name.
- Keep Field name, invalid state, Form errors, and FieldError synchronized.
- Submit and reset Buttons need explicit visible action labels.
- Move focus or provide an error summary when submission fails across several fields.
Implementation Guidance
- Use Form for workflows with several related fields and shared submission or errors.
- Do not use raw form controls without Field connections in visible app flows.
- Keep server and client errors in the same Field error contract.