Forms
Navigation & layout
Data display & feedback
Date & time
Browse components
← All components
Form
Accessible form root from Base UI.
Install
npx shadcn@latest add https://ui.anuragroy.dev/r/form.jsonPreview
Loading preview…
Installation
Add the component from this site. The shadcn CLI fetches the registry JSON over HTTPS — no named registry submission required.
Terminal
npx shadcn@latest add https://ui.anuragroy.dev/r/form.jsonGitHub fallback if the website is down:
Terminal
npx shadcn@latest add https://raw.githubusercontent.com/anurag-roy/ui.anuragroy.dev/main/public/r/form.jsonUsage
Import paths follow your components.json aliases. After install, the default path is @/components/ui/form.
Import
import { Form } from "@/components/ui/form"example.tsx
import { Button } from "@/components/ui/button"import { Form } from "@/components/ui/form"import { TextField, TextFieldError, TextFieldInput, TextFieldLabel,} from "@/components/ui/text-field"export function Example() { return ( <Form className="flex flex-col gap-3" onSubmit={(event) => event.preventDefault()} > <TextField name="name"> <TextFieldLabel>Name</TextFieldLabel> <TextFieldInput placeholder="Your name" required /> <TextFieldError match="valueMissing">Name is required.</TextFieldError> </TextField> <Button type="submit">Save</Button> </Form> )}API Reference
Form
Base UI Form. Native form props plus validation wiring for Field children.
| Prop | Type | Default |
|---|---|---|
| onSubmit | React.FormEventHandler<HTMLFormElement> | — |
- onSubmit — Native submit handler. Call `event.preventDefault()` for client-side forms.