What the component guarantees
- A native field. It renders a real
<input>(or<textarea>withmultiline), so typing, selection, autofill, the on-screen keyboard and the reader's own field commands all work as the platform intends.$attrsland on the native element, soautocomplete,inputmodeandaria-*you pass reach it. - A label tied to the field.
labelrenders anNbLabel(or, influid, a<label>inside the box, which floats above the value but stays the same element) whoseformatches the field's id.requiredsets the nativerequiredand shows an asterisk that isaria-hidden, so it is not read as "star". - Validation a reader hears.
- With
error, the field carriesaria-invalid="true". - The visible message (error, then warning, then helper) has its own id,
{id}-error,{id}-warningor{id}-helper, and the field points at it witharia-describedby. Anaria-describedbyyou pass yourself is kept beside it. - A message present on first render is read when the field takes focus, and is not announced on load, so a form returned with server errors does not shout.
- An error that appears or changes after mount mounts with
role="alert"; a warning withrole="status". - In
fluid, the message is an icon with a tooltip; its text stays in the accessibility tree, visually hidden, soaria-describedbystill reads it.
- With
- Text a phone will not zoom. Field text is at least 16px on a phone touch screen, so iOS does not zoom the page when the field takes focus.
- Tested in
tests/TextInput.test.tsandtests/fieldValidationAria.test.ts, and by axe intests/axe.test.ts.
Keyboard
The browser's own. Tab reaches the field; everything inside it is native text editing. Buttons you put in the #actions slot, and the built-in clear and reveal buttons, are separate tab stops after the field. With clearable, Escape in a field that has a value empties it, and the key goes no further, so a dialog around the field stays open. On an empty field Escape is left alone.
What you own
- A label. A placeholder is not a label: it disappears on the first keystroke and most readers treat it as a hint at best. Use
label, the#labelslot, oraria-label. autocompleteon personal data fields (email,name,tel,street-address), which WCAG 1.3.5 asks for and password managers rely on.- When to validate. Showing an error on every keystroke announces an alert on every keystroke. Validate on blur or on submit, and after a failed submit move focus to the first invalid field.
- Error text that says how to fix it. "Enter an email like name@example.com" rather than "Invalid".
- The names of
#actionsbuttons. Give each one alabel, which names it and shows the same words as its tooltip. The built-in clear and reveal buttons (clearable,revealable) are already named, from the string catalogue, and the reveal button's name follows its state ("Show password", "Hide password").
Known gaps
- With
highlight, the native field is transparent over a mirror. It stays the real field for every assistive technology, but the colours a reader of the screen sees come from the mirror and are not measured by the contrast tests. - No manual screen reader pass has been recorded for this component.