Auto Form
InputMITSchema-driven auto-generated form from a Zod schema — labels, helpers, and validation.
bun add @otfdashkit/ui
Preview
Auto FormInput
Loading Storybook preview…
Code
@otfdashkit/uiimport * as z from 'zod'
import { AutoForm } from '@otfdashkit/ui'
const registrationSchema = z.object({
name: z.string().min(2),
email: z.email(),
age: z.number().min(18).max(120),
role: z.enum(['admin', 'editor', 'viewer']),
newsletter: z.boolean().optional(),
startDate: z.date().optional(),
})
export function Example() {
return (
<div className="max-w-sm">
<AutoForm
schema={registrationSchema}
onSubmit={(data: unknown) => alert(JSON.stringify(data, null, 2))}
defaultValues={{ role: 'viewer', newsletter: false }}
submitLabel="Register"
/>
</div>
)
}
Free with the SDK. This component ships in @otfdashkit/ui under the MIT license.
Props
Props declared in the AutoForm source. Inherited HTML attributes are not listed.
| Prop | Type | Default | Description |
|---|---|---|---|
| onSubmitrequired | (data: Record<string, unknown>) => void | ||
| schemarequired | ZodObject<Readonly<{ [k: string]: $ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>; }>, $strip> | ||
| defaultValues | Record<string, unknown> | ||
| submitLabel | string | 'Submit' |