AutoForm
React

Getting Started

New to AutoForm? Check out the introduction first.

Migrating from the old shadcn/ui component? Check out the migration guide.

Install the AutoForm Agent Skill (optional)

If you use AI coding assistants (such as Cursor, Claude Code, Opencode, or GitHub Copilot), you can install the AutoForm skill. It gives your coding agent access to AutoForm-specific documentation, examples, and best practices.

npx skills add https://github.com/adityacodepublic/autoform/tree/acp-package/skills --skill autoform
pnpm dlx skills add https://github.com/adityacodepublic/autoform/tree/acp-package/skills --skill autoform
yarn skills add https://github.com/adityacodepublic/autoform/tree/acp-package/skills --skill autoform
bunx --bun skills add https://github.com/adityacodepublic/autoform/tree/acp-package/skills --skill autoform

Install AutoForm's integration to your UI library

AutoForm integrates directly into your UI library to render forms. You can choose from the following official integrations:

Before installing an @autoform UI package make sure you have installed:

react-hook-form

@hookform/resolvers

Shadcn/ui

npx shadcn@latest add https://raw.githubusercontent.com/adityacodepublic/autoform/refs/heads/acp-package/packages/shadcn/registry/autoform.json
pnpm dlx shadcn@latest add https://raw.githubusercontent.com/adityacodepublic/autoform/refs/heads/acp-package/packages/shadcn/registry/autoform.json
yarn shadcn@latest add https://raw.githubusercontent.com/adityacodepublic/autoform/refs/heads/acp-package/packages/shadcn/registry/autoform.json
bunx --bun shadcn@latest add https://raw.githubusercontent.com/adityacodepublic/autoform/refs/heads/acp-package/packages/shadcn/registry/autoform.json

Use import { AutoForm } from "@/components/ui/autoform" to import the component. By default, the registry will use the zod integration. If you want to use another schema library, simply update the /components/ui/autoform/utils.ts file.


Material UI

peer dependencies
{
  "@mui/material": "^6",
  "@emotion/react": "^11",
  "@emotion/styled": "^11"
}
npm install @mui/material@^6 @emotion/react@^11 @emotion/styled@^11
pnpm add @mui/material@^6 @emotion/react@^11 @emotion/styled@^11
yarn add @mui/material@^6 @emotion/react@^11 @emotion/styled@^11
bun add @mui/material@^6 @emotion/react@^11 @emotion/styled@^11
npm install @acp-autoform/mui
pnpm add @acp-autoform/mui
yarn add @acp-autoform/mui
bun add @acp-autoform/mui

Mantine

peer dependencies
{
  "@mantine/core": "^7",
  "@mantine/dates": "^7"
}
npm install @mantine/core@^7 @mantine/dates@^7
pnpm add @mantine/core@^7 @mantine/dates@^7
yarn add @mantine/core@^7 @mantine/dates@^7
bun add @mantine/core@^7 @mantine/dates@^7
npm install @acp-autoform/mantine
pnpm add @acp-autoform/mantine
yarn add @acp-autoform/mantine
bun add @acp-autoform/mantine

Ant Design

peer dependencies
{
  "antd": "^5"
}
npm install antd@^5
pnpm add antd@^5
yarn add antd@^5
bun add antd@^5
npm install @acp-autoform/ant
pnpm add @acp-autoform/ant
yarn add @acp-autoform/ant
bun add @acp-autoform/ant

Chakra UI

peer dependencies
{
  "@chakra-ui/react": "^3.8",
  "@emotion/react": "^11.14"
}
npm install @chakra-ui/react@^3.8 @emotion/react@^11.14
pnpm add @chakra-ui/react@^3.8 @emotion/react@^11.14
yarn add @chakra-ui/react@^3.8 @emotion/react@^11.14
bun add @chakra-ui/react@^3.8 @emotion/react@^11.14
npm install @acp-autoform/chakra
pnpm add @acp-autoform/chakra
yarn add @acp-autoform/chakra
bun add @acp-autoform/chakra

If you want to integrate into your own UI components or another UI library, check out the custom integration guide.

In the docs, we will use Shadcn UI as an example but simply replace the imports with the ones from your UI library.

Install AutoForm's integration to your schema library

Zod

npm install @acp-autoform/zod
pnpm add @acp-autoform/zod
yarn add @acp-autoform/zod
bun add @acp-autoform/zod
requires zod version greater than 3.25.0 to be installed

Yup

npm install @acp-autoform/yup
pnpm add @acp-autoform/yup
yarn add @acp-autoform/yup
bun add @acp-autoform/yup

Joi

npm install @acp-autoform/joi
pnpm add @acp-autoform/joi
yarn add @acp-autoform/joi
bun add @acp-autoform/joi

In the docs, we will use Zod as an example but simply replace the imports with the ones from your schema library.

Create a form

import * as z from "zod";
import { AutoForm } from "@acp-autoform/mui";
import { ZodProvider } from "@acp-autoform/zod";

const mySchema = z.object({
  name: z.string(),
  age: z.coerce.number(),
});
const schemaProvider = new ZodProvider(mySchema);

function MyForm() {
  return (
    <AutoForm
      schema={schemaProvider}
      onSubmit={(data, form) => {
        console.log(data);
      }}
      withSubmit
    />
  );
}

export default MyForm;

Next.js and RSC

AutoForm can only be used inside a client-side React component due to serialization of the schema. If you want to use it in a Next.js app, mark your component with "use client".

// MyPage.tsx
export default function MyPage() {
  return (
    <div>
      <MyForm />
    </div>
  );
}

// MyForm.tsx
"use client";
import { AutoForm } from "@acp-autoform/mui";
export default function MyForm() {
  return <AutoForm ... />;
}

Submitting the form

You can use the withSubmit prop to automatically add a submit button to the form.

<AutoForm
  // ...
  withSubmit
/>

Adding other elements

All children passed to the AutoForm component will be rendered below the form.

<AutoForm>
  <p className="text-gray-500 text-sm">
    By submitting this form, you agree to our{" "}
    <a href="#" className="text-primary underline">
      terms and conditions
    </a>
    .
  </p>
</AutoForm>

Accessing the form data and methods

AutoForm gives you several ways to access the form state and methods — via onSubmit, useFormContext, or an external formControl. See more.

Custom field components

When creating custom field components, you can use useController() from react-hook-form to register the field and access the field's methods and state. To learn more about creating custom fields, see customization.

Next Steps

On this page