InputField

Accessibility

Accessibility props

NameTypeDescription
labelTranslationProvides a visible label that is associated with the input field.
rolestringDefines the role of the input element, which helps screen readers understand its purpose and behavior.
ariaLabelstringAdds an aria-label to the input, providing a description for screen readers when no visible label is present.
ariaLabelledbystringReferences the ID of an element that labels the input, establishing a relationship for screen readers.
ariaDescribedbystringReferences the ID of an element that describes the input, useful for associating additional information with the field.
ariaAutocompleteinline \| list \| both \| noneIndicates to screen readers whether and how the input provides autocomplete suggestions.
ariaActiveDescendantstringIdentifies the currently active descendant in a composite widget, such as when navigating through autocomplete suggestions.
ariaHasPopupbooleanIndicates to screen readers that the input can trigger a popup, like a dropdown menu or dialog.
ariaExpandedbooleanIndicates to screen readers whether the associated popup or dropdown is currently expanded.
ariaControlsstringIdentifies the element controlled by the input, establishing a relationship for screen readers.

Automatic Accessibility Features

    • When the component is not inside an InputGroup and has error or help text, a unique ID is generated (based on the input’s ID) and is combined with the ariaDescribedby prop to ensure all descriptions are announced by screen readers.
    • When the component is inside an InputGroup, the InputGroup completely overrides any ariaDescribedby value that was set on the InputField. The InputGroup sets its own feedback ID as the aria-describedby value if there are any error or help values and the tooltip is shown.

Best practices

Examples

Basic InputField with label

<InputField label="Email address" placeholder="your@email.com" type="email" name="email" required />

InputField with autocomplete

<InputField
label="City"
placeholder="Start typing..."
role="combobox"
ariaHasPopup={true}
ariaExpanded={suggestionsVisible}
ariaControls="city-suggestions"
ariaAutocomplete="list"
ariaActiveDescendant={activeItemId}
/>

Using ariaDescribedby for enhanced accessibility

<InputField label="Password" type="password" ariaDescribedby="password-requirements" />
<p id="password-requirements" style={{ display: "none", visibility: "hidden" }}>
Password must be at least 8 characters long and include at least one uppercase letter and one number.
</p>
<InputField label="Username" error="This username is already taken" />
<InputField label="Email" error="Invalid email format" ariaDescribedby="email-hint" />
<p id="email-hint" style={{ display: "none", visibility: "hidden" }}>
We'll never share your email with anyone else.
</p>

InputGroup Integration

Group-level error/help messages

<InputGroup label="Passenger details" error="Incomplete information">
<InputField label="First name" />
<InputField label="Last name" />
</InputGroup>

Component-level error/help messages

<InputGroup label="Passenger details">
<InputField label="First name" />
<InputField label="Last name" error="Last name is required" />
</InputGroup>

Component-level ariaDescribedby value

<InputGroup label="Contact information">
<Select options={countryOptions} label="Country" />
<InputField
label="Phone number"
ariaDescribedby="phone-hint" // This will be overwritten
/>
<p id="phone-hint" style={{ display: "none", visibility: "hidden" }}>
Enter your phone number
</p>
</InputGroup>