FormField
Wrapper that pairs any form control (TextInput, TextArea, SelectField, Checkbox, RadioGroupItem, Switch) with a label, helper text and error state. It wires id, htmlFor, aria-invalid and aria-describedby automatically.
Playground
Live preview
Helper text shown under the control.
Examples
With different controls
Used for notifications.
<FormField label="Email" hint="Used for notifications." required>
<TextInput type="email" placeholder="you@example.com" />
</FormField>
<FormField label="Bio">
<TextArea placeholder="Tell us about yourself..." />
</FormField>
<FormField label="Country">
<SelectField
placeholder="Select a country"
options={[
{ value: "es", label: "Spain" },
{ value: "us", label: "United States" },
]}
/>
</FormField>States
Username is already taken.
Referrals open after onboarding.
// Error — control renders with status-danger styling, message has role="alert"
<FormField label="Username" error="Username is already taken.">
<TextInput defaultValue="hunter_42" />
</FormField>
// Forced invalid without a message
<FormField label="Invite code" invalid>
<TextInput placeholder="XXXX-XXXX" />
</FormField>
// Readonly — value stays readable, control is not editable
<FormField label="Wallet address" readOnly>
<TextInput readOnly defaultValue="0x1234…abcd" />
</FormField>
// Disabled
<FormField label="Referral" disabled hint="Referrals open after onboarding.">
<TextInput placeholder="Coming soon" />
</FormField>Checkables
Email and push.
<FormField orientation="horizontal" label="Accept terms and conditions" required>
<Checkbox />
</FormField>
<FormField orientation="horizontal" label="Enable notifications" hint="Email and push.">
<Switch />
</FormField>
<RadioGroup defaultValue="public">
<FormField orientation="horizontal" label="Public profile">
<RadioGroupItem value="public" />
</FormField>
<FormField orientation="horizontal" label="Private profile">
<RadioGroupItem value="private" />
</FormField>
</RadioGroup>Code
import { FormField, TextInput } from "@npolyhunter/ui";
// Label + control + hint, wiring id / htmlFor / aria-describedby for you
<FormField
label="Email"
hint="We never share your email."
required
>
<TextInput type="email" placeholder="you@example.com" />
</FormField>
// Error state — invalid is forced on the control and the message is wired
// with role="alert" + aria-describedby
<FormField label="Email" error="Enter a valid email address.">
<TextInput type="email" defaultValue="not-an-email" />
</FormField>
// Checkables — horizontal orientation puts the label beside the control
<FormField orientation="horizontal" label="Accept terms">
<Checkbox />
</FormField>Code
// Controls share the same props: invalid, disabled, readOnly are
// forwarded to the control; error overrides invalid styling.
<FormField
label="${label}"
hint="Helper text shown under the control."
required={required}
disabled={disabled}
readOnly={readOnly}
>
<TextInput placeholder="Type here..." />
</FormField>Used in
Includes use through shared UI components.
AppBack Office
