Form fields are a fundamental interface element. They’re also hard to get right: you need to think about hover animations, focusing, overriding user-agent stylesheets, cursors, disabled states, ‘readonly’ inputs, validation, borders, line heights, and more. Fortunately, a17t does all this for you.
.field selector whenever you want a form-style field to look nice. Fields are especially useful for textareas and text inputs.
Multiple (adjacent) fields — You can build adjacent fields by removing the left or right border from the fields and setting their x-margin to zero. Beware that using adjacent fields can result in a poor user experience on mobile.
Backwards compatability — Prior to v0.10.0, a17t had two other elements (
.textarea) that were identical to
.field under the hood. For simplicity, these elements are all consolated under
.field. Now, we recommend you just use
.field. (That being said,
.textarea will continue to work — we don’t want your code to break!)
Fields have full tone support.
Use Aria roles and labels. When building forms, it’s easy to rely on visual guidelines to show relationships between elements. Unfortunately, this doesn’t help those interacting with your site using a screenreader or other assistive technologies. For this reason, it’s important to use ARIA labels and roles wherever possible.
Don't use color to communicate. Instead, use color to support information you communicate through text. When this isn't possible, be sure to use a
Be mindful of contrast. What looks good to you may not be readable for others. Text contrast is a good thing!
Support all navigation modes. Some people will interact with your interface using assitive technologies and/or a keyboard. Build your interface with these different modes in mind (for example, by setting the `tab-index` attribute on all interactive elements that aren't interactive by default).