Form

A form wraps a group of form elements and handles form submission.

Please enter your full name.
<FormPrimitives.Form onSubmit={handleSubmit} className="w-xs space-y-4">
  <TextField isRequired>
    <Label>Name</Label>
    <Input name="name" minLength={2} placeholder="Name" />
    <Description>Please enter your full name.</Description>
  </TextField>
  <Button variant="primary" type="submit">
    Submit
  </Button>
</FormPrimitives.Form>

Installation

npx shadcn@latest add @dotui/form

Usage

Use forms to wrap groups of form elements and handle form submission with validation.

import { Form } from "@/components/ui/form";
import { Button } from "@/components/ui/button";
import { TextField } from "@/components/ui/text-field";
import { Label } from "@/components/ui/field";
import { Input } from "@/components/ui/input";
<Form onSubmit={handleSubmit}>
	<TextField name="email" isRequired>
		<Label>Email</Label>
		<Input />
	</TextField>
	<Button type="submit" variant="primary">
		Submit
	</Button>
</Form>

Examples

Please enter your full name.

Register

Gender
Birth Date
How did you hear about us?

API Reference

PropTypeDefaultDescription
validationBehavior'native' | 'aria''native'Whether to use native HTML form validation or ARIA.
validationErrorsValidationErrors-Validation errors to display on form fields.
actionstring | FormHTMLAttributes<HTMLFormElement>['action']-The URL to submit the form to.
encTypestring-The encoding type to use for form submission.
methodstring-The HTTP method to use for form submission.
targetstring-The target window for form submission.
autoCompletestring-Whether the browser should autocomplete the form.
autoCapitalizestring-Whether text should be auto-capitalized.
childrenReactNode-The form content.
EventTypeDescription
onSubmit(e: FormEvent<HTMLFormElement>) => voidHandler that is called when the form is submitted.
onReset(e: FormEvent<HTMLFormElement>) => voidHandler that is called when the form is reset.
onInvalid(e: FormEvent<HTMLFormElement>) => voidHandler that is called when validation fails.

Last updated on 5/22/2026