Schema-driven form primitives. Zod schema as source of truth — field types inferred, validation wired, accessibility baked in. Built on react-hook-form + vUi.
npm install @booga/vformsimport { z } from 'zod'
import { Form, Field, Submit, Reset } from '@booga/vforms'
const schema = z.object({
email: z.string().email(),
role: z.enum(['admin', 'user']),
active: z.boolean(),
})
function MyForm() {
return (
<Form schema={schema} onSubmit={console.log} defaultValues={{ active: true }}>
<Field name="email" label="Email" />
<Field name="role" label="Role" />
<Field name="active" label="Active" />
<Submit />
<Reset />
</Form>
)
}| Zod type | Rendered primitive |
|---|---|
z.string() |
<input type="text"> |
z.number() |
<input type="number"> |
z.boolean() |
<button role="switch"> |
z.enum() / z.nativeEnum() |
<select> |
z.date() |
<input type="date"> |
Wrappers (optional, nullable, default, refine, transform, pipe, brand, catch) are recursively stripped — the inner type drives dispatch.
<Field name="bio" as={MyCustomInput} multiline />Custom components receive ControlledFieldProps: value, onChange, onBlur, name, id, aria-invalid, aria-describedby.
import { VFormsConfigSchema } from '@booga/vforms'
VFormsConfigSchema.parse({
validationMode: 'onChange', // 'onSubmit' | 'onChange' | 'onBlur'
resetOnSuccess: true,
})FieldGroup — <fieldset> with optional legend, groups related fields semantically.
FieldRow — horizontal flex container for side-by-side fields.
InputField, TextareaField, SelectField, SwitchField, CheckboxField, RadioGroupField, DatePickerField — all exported for custom form layouts outside the Field dispatcher.