ErlangFormDocs v1.0.0
Basic fields

Checkbox

Render a boolean field as a checkbox.

z.boolean() renders a checkbox. Checked stores true and unchecked stores false. Initialize the field with a boolean in defaultValues.

Usage

Use your form instance from useForm. See the initial setup.

example.tsx
const schema = z.object({ active: z.boolean() });

<ErlForm
  form={form}
  schema={schema}
  fieldConfig={{
    active: { label: "Active" },
  }}
/>

To require explicit acceptance, add a Zod rule that accepts only true; a boolean schema alone also accepts false. For multiple string choices, use a checkbox group.

Native readonly does not prevent checkbox toggling in browsers. Use disableIf or a custom component when changes must be blocked.

On this page