Skip to content

Browse components

← All components

Form

Accessible form root from Base UI.

Install
npx shadcn@latest add https://ui.anuragroy.dev/r/form.json

Preview

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.json

GitHub fallback if the website is down:

Terminal
npx shadcn@latest add https://raw.githubusercontent.com/anurag-roy/ui.anuragroy.dev/main/public/r/form.json

Usage

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.

PropTypeDefault
onSubmitReact.FormEventHandler<HTMLFormElement>—
  • onSubmit — Native submit handler. Call `event.preventDefault()` for client-side forms.