Form Field
v0.3.0Dumb 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`.
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
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.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
label | ReactNode | — | Field label |
htmlFor | string | — | Associates the label with the control — pass the same id you give the control |
hint | ReactNode | — | Supporting hint text; hidden while error is present |
error | ReactNode | — | Error message; also visually marks the field as invalid |
required | boolean | false | Shows a required marker next to the label |
children | ReactNode | — | The form control this field wraps (required) |
className | string | — | Additional class names |
Compositions
Open all 4 →Properties
FormField props
| Prop | Type | Default | Description |
|---|---|---|---|
children* | ReactNode | — | The form control this field wraps |
className | string | — | Additional class names to merge with the component root element |
error | ReactNode | — | Error message; also visually marks the field as invalid |
hint | ReactNode | — | Supporting hint text; hidden while `error` is present |
htmlFor | string | — | Associates the label with the control — pass the same id you give the control |
label | ReactNode | — | Field label |
required | boolean | — | Shows a required marker next to the label |
Also accepts the native attributes of its root element (className, aria-*, event handlers, …).