Dumb wrapper that provides label + hint/error + required-marker layout around any form control (`Checkbox`, `Input`, `Textarea`, `Select`, `Toggle`, ...) — the same job AntD's `Form.Item` does. The control itself owns none of this chrome; it just needs an `id` matching `htmlFor`.

pnpm add @behivetech/forms.form-field

You are viewing Form Field v0.3.4, snapshotted 2026-11-09. The latest is v0.3.5. Go to the latest →

Dumb wrapper that provides label + hint/error + required-marker layout around any form control (Checkbox, Input, Textarea, Select, Toggle, ...) — the same job AntD's Form.Item does. The control itself owns none of this chrome; it just needs an id matching htmlFor.

Usage

1import { FormField } from '@behivetech/forms.form-field';
2import { Checkbox } from '@behivetech/atoms.checkbox';
3
4<FormField label="Accept terms" htmlFor="terms" required>
5 <Checkbox id="terms" />
6</FormField>
7
8<FormField label="Email" htmlFor="email" hint="We'll never share this">
9 <input id="email" type="email" />
10</FormField>
11
12<FormField label="Email" htmlFor="email" error="A valid email is required">
13 <input id="email" type="email" />
14</FormField>

hint is hidden whenever error is present. If label, hint, and error are all omitted, FormField renders as a plain wrapper around children.

Known limitation: FormField doesn't automatically wire aria-describedby from the control to the hint/error text — pass it yourself if you need that linkage today.

Properties

FormField props

PropTypeDefaultDescription
children*ReactNode—The form control this field wraps
classNamestring—Additional class names to merge with the component root element
errorReactNode—Error message; also visually marks the field as invalid
hintReactNode—Supporting hint text; hidden while `error` is present
htmlForstring—Associates the label with the control — pass the same id you give the control
labelReactNode—Field label
requiredboolean—Shows a required marker next to the label

Also accepts the native attributes of its root element (className, aria-*, event handlers, …).