Field
In your time zone.
In your time zone.
A label, helper text and error around a control DIYA doesn't make: your own input, a native one DIYA doesn't wrap, or a third-party or hosted control.
A Markdown brief for Claude, Cursor or v0: install, setup, props and a complete example.
For a control DIYA doesn’t make: your own input, a native one DIYA doesn’t wrap (time, color), or a third-party or hosted control. Field gives it the label, help and error every DIYA field has.
DIYA makes the control? Use its own label, helperText and error. A payment provider’s card field? Field with framed draws the field box around it.
The label points at the control, the help or error is linked with aria-describedby, and an error sets aria-invalid. A hosted iframe is named with aria-labelledby, a label click moves focus into it, and its error is spoken as focus arrives, since ids can’t reach inside a frame.
import { Field } from '@idyeah/diya'Stable since 1.2.0
childrenRequiredReactElement<any, string | React.JSXElementConstructor<any>> | ((control: FieldControlProps) => ReactNode)One control element, which gets the ids and states merged in; or a function that receives them, for a control that takes them somewhere else.
labelRequiredstringVisible label above the control; also its accessible name. Hide it with hideLabel.
disabledbooleanDims the field and passes disabled to the control; put the reason in helperText.
errorstringVisible error message below the control; marks the field invalid while set.
framedbooleanDraws DIYA's field box (fill, edge, corner, height and focus ring) around a control that has none, such as a payment provider's card iframe or a native time input. A label click focuses the iframe; if your provider needs its own focus() to reach its input (Stripe, Braintree), call it from the label: onClick={(event) => { if ((event.target as Element).closest('label')) card.focus() }}. Defaults to false.
Default false
helperTextstringVisible hint below the control, announced with it; error replaces it while set.
hideLabelbooleanHides the label visually but keeps it as the control's accessible name.
Default false
idstringThe control's id, for a function child or a child without its own id; a child's own id wins. Defaults to a generated one.
requiredbooleanTells assistive tech the control is required (aria-required) and draws nothing. Mark the few optional fields with "(optional)" in their label instead.
size"small" | "medium" | "large"With framed, the frame's height and text size; defaults to 'medium'.
Default 'medium'
Also takes every native <div> attribute, such as id, aria-* or data-*.