Field
A compound wrapper for labelled form fields with helper and error text.
Import
import { Field } from '@oztix/roadie-components/field'
Examples
Default
<Field> <Field.Label>Name</Field.Label> <Field.Input placeholder='Enter your name' /> </Field>
With indicators
Use showIndicator on Field.Label to automatically render a required or
optional indicator based on the Field's required prop. This eliminates the
need to manually import and place RequiredIndicator or OptionalIndicator.
States
Fields inherit input interaction states. Focus shows accent colouring,
invalid shows danger colouring with error text. The invalid and disabled
props flow through context to child inputs automatically.
Composition
Field exposes sub-components for label, input, textarea, helper text, and error text.
With helper text
<Field> <Field.Label>Email</Field.Label> <Field.Input type='email' placeholder='you@example.com' /> <Field.HelperText>We will never share your email.</Field.HelperText> </Field>
With error text
Set invalid on the Field root to activate the danger state. The input
border and focus ring automatically switch to danger colours, and
aria-invalid is set on the input automatically.
<Field invalid> <Field.Label>Password</Field.Label> <Field.Input type='password' /> <Field.ErrorText>Password must be at least 8 characters.</Field.ErrorText> </Field>
With textarea
<Field> <Field.Label>Bio</Field.Label> <Field.Textarea placeholder='Tell us about yourself' /> <Field.HelperText>Maximum 200 characters.</Field.HelperText> </Field>
Accessibility
- Auto-wired IDs: Field auto-generates matching IDs for the label, input, helper text, and error text. You don't need to set
htmlFororidmanually. - Context-driven aria: The
invalid,required, anddisabledprops on Field automatically setaria-invalid,aria-required, anddisabledon child inputs via context. - Error announcements:
Field.ErrorTextrenders withrole="alert"and only appears wheninvalidis true, so screen readers announce errors immediately. - Description linking:
aria-describedbyis automatically wired to the helper text (or error text when invalid).
API reference
Field
Field.ErrorText
No additional props — forwards all standard HTML attributes to the underlying element.
Field.HelperText
No additional props — forwards all standard HTML attributes to the underlying element.
Field.Input
Field.Label
Field.Textarea
Inherited from TextareaProps