Form

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

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

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 1/13/2026

Built with passion by @mehdibha.