Tagged “forms”
Form accessibility and usability beyond the basics, on popetech
Whitney Lewis covers four accessibility considerations for implementing forms: autofill, error messaging, date fields and auto-formatting fields.
I found the explanatations of the autocomplete
attribute and the section on an accessible error message pattern particularly useful. The latter part felt similar to the good advice Adam Silver gives in his book Form Design Patterns.
No Style Design System
Adam Silver’s collection of accessible form-related components – a companion to his book Form Design Patterns – is a brilliant reference.
In there you’ll find Autocomplete, date fields, validation and lots of other tricky components and patterns.
How to build an accesssible autocomplete
At work there are plans afoot to reconcile various differing Autocomplete implementations into a single, reusable component. So far there’s been a written audit presenting all instances and how they differ in functional and technical respects. There’s also been design work to identify visual commonalities and avoid future inconsistencies. I’d now like to add another perspective: an investigation into which HTML materials and (if necessary) ARIA supplements are appropriate to ensure we build something accessible and resilient.
My experience is that to achieve the right result, HTML semantics and related concerns can’t just follow and bend to spec and visual design goals, but rather must influence the setting of those goals.
I’ll flesh out my findings in due course, but for now here are the key resources I’ve identified and plan to dig deep into.
Adrian Roselli’s article Stop Using ‘Drop-down’. To summarise the options of interest:
- ARIA Listbox lets you create a DIY thing that has the same roles and semantics as a
<select>
but where you have greater stylistic control. There are different ways to implement a Listbox. Datalist
is the native HTML version of a combo box. A combo box is essentially a<select>
with a text field.Datalist
is announced by screen readers in different ways but as far as I can gather these are quirky rather than terrible. I found a nice Twitter thread on DataList which not only shows off its function but also includes a promising accessibility-related comment from Patrick H Lauke of Tetralogical. The drawback, becauseDatalist
is native HTML, is that its options are not stylelable.- ARIA Combobox is a pattern that combines ARIA
combobox
,textbox
andlistbox
roles, and the benefit it brings is to allow a level of custom design that you couldn’t achieve withDatalist
. Autocomplete
(not to be confused with the HTMLautocomplete
attribute) describes a control which provides users with suggestions that may not be available in the DOM already… for example when you fetch options via Ajax in reponse to what the user types.
With regard to Autocomplete, Adrian points to Adam Silver’s Building an accessible autocomplete control.
And for advice on whether or not to go with a native select or a custom control, and how best to implement listbox and combobox if that’s your choice, Adrian points to the following resources from Sarah Higley:
<select>
your poison part 2 (see the Roll your own section at bottom)- Recommended Combobox Patterns pen
I also see that GOV.UK have marked a possible Autocomplete component as one of their next priorities to review. Their Autocomplete discussion thread includes examples and research and will be really helpful.
Custom multi-checkbox and multi-radio controls
Our Design System team has recently received “new component requests” for some custom filtering controls. These look like custom-styled <select>
s however their “options” appear more like checkboxes and radio buttons. I think the inspiration was Carbon Design System’s Dropdown component and the idea is to bring consistency to filtering controls in forms. Although it’s not yet time to fully explore this and make a yay/nay decision on the request, I’ve been doing some initial thinking.
(Note: this post is kinda a journey and work-in-progress. I’ll return to complete it and tidy up. For now it serves as a handy log of my research.)
When this was first mooted without guide designs, I assumed we’d be making a custom select. Filament Group have previously shown how to style one of those, although that only affects the “trigger” part. CSS can’t yet style the options. That then led me to check in on the progress of Open UI’s selectmenu element which does support styling the options however it appears that it’s far from road-ready.
However then I saw the designs and realised that while the outside looks like a select, the options look like a group of checkboxes or (kinda) like radio buttons, rather than typical <select>
options. And of course the checkboxes and radio buttons themselves are custom-styled.
This led me to reading the following resources.
- Under-engineered multi-selects
- Under-engineered select menus
- Under-engineered custom radio buttons and checkboxen
- Inclusively Hiding & Styling Checkboxes and Radio Buttons
Léonie Watson’s post Perceived affordances and the functionality mismatch is also looming large in the back of my mind.
Simple input[type=range] styling, by Ana Tudor
Ana demonstrates how to achieve a range slider effect accessibly, using web standards and without needing to reach for libraries.
As Ana’s tweet explains, this offers a number of features and benefits:
- can drag thumb with JS disabled
- receives focus
- keyboard navigation
- clicking track moves thumb there and changes slider value
- seen as slider in Accessibility panel
- no library needed, so less code in total
A better birthday input, by Vitaly Friedman
I recently signed up to Vitaly from Smashing Mag’s Smart Interface Design Patterns newsletter. This latest edition regarding “date of birth” inputs was interesting, and well timed as my work colleagues and I are about to revisit our form patterns. It’s a nice explainer on why we should approach UI for dates the user knows differently from UI for dates the user will choose.
Vitaly recommends that when asking the user for a very specific date that they already know without needing to consult a calendar, drop-downs and calendar look-ups are unnecessary. And avoiding them is probably ideal, because <input type=date>
and <select>
based interfaces have some usability and accessibility kinks, as do many date-picker libraries.
It’s better to rely on three simple, adjacent text input fields with a label above each field. See GOV.UK’s Date input component for a great example.
Date pickers should only be required when you’re asking for a date that the user will choose (say, booking a holiday or appointment) rather than one they’ll know. Vitaly doesn’t recommend a date picker, but I reckon the date-picker web component from the clever folks behind the Duet Design System could be a good option.
Oh, and this also reminds me that I need to get the finger out and pick up a copy of Adam Silver’s Form Design Patterns.
The accessibility of conditionally revealed questions (on GOV.UK)
Here’s something to keep in mind when designing and developing forms. GOV.UK’s accessibility team found last year that there are some accessibility issues with the “conditional reveal” pattern, i.e. when selecting a particular radio button causes more inputs to be revealed.
The full background story is really interesting but the main headline seems to be: Keep it simple.
- Don’t reveal any more than a single input, otherwise the revealed section should not be in a show-and-hide but rather in its own form in the next step of the process.
- Conditionally show questions only (i.e. another form input such as Email address)—do not show or hide anything that’s not a question.
Doing otherwise causes some users confusion making it difficult for them to complete the form.
See also the Conditionally revealing a related question section on the Radios component on the GDS Design System
How-to: Create accessible forms - The A11Y Project
Here are five bite-sized and practical chunks of advice for creating accessible forms.
- Always label your inputs.
- Highlight input elements on focus.
- Break long forms into smaller sections/pages.
- Provide error messages (rather than just colour-based indicators)
- Avoid horizontal layout forms unless necessary.
I already apply some of these principles, but even within those I found some interesting takeaways. For example, the article advises that when labelling your inputs it’s better not to nest the input within a <label>
because some assistive technologies (such as Dragon NaturallySpeaking) don’t support it.
I particularly like the idea of using CSS to make the input which has focus more obvious than it would be by relying solely on the text cursor (or caret).
input:focus {
outline: 2px solid royalblue;
box-shadow: 1px 1px 8px 1px royalblue;
}
(via @adactio)
Inclusive Datepicker (by Tommy Feldt)
A human-friendly datepicker. Supports natural language manual input through Chrono.js. Fully accessible with keyboard and screen reader.
Sign-in form best practices (on web.dev)
Sam Dutton advises how to use cross-platform browser features to build sign-in forms that are secure, accessible and easy to use.
The tips of greatest interest to me were:
- on using
autocomplete="new-password"
on registration forms andautocomplete="current-password"
on sign-in forms to tap into browser password suggestion and password manager features; - on how best to provide “Show Password” functionality; and
- on using
aria-describedby
when providing guidance on password rules.
HTML attributes to improve your users’ two factor authentication experience (Twilio
In this post we have seen that with just a sprinkling of HTML attributes we can improve the login experience for our users, particularly on mobile devices.
By adding certain attributes to the HTML input
element – such as inputmode
, pattern
and autocomplete="current-password"
– we can improve the user experience when logging in.
HTML: The Inaccessible Parts (daverupert.com)
Here’s Dave Rupert, frustratedly rounding up the accessibility shortfalls in browser implementations of native HTML elements.
I’ve always abided in the idea that “HTML is accessible by default and then we come along and mess it up”. But that’s not always the case. There are some cases where even using plain ol’ HTML causes accessibility problems.
(via @jamesmockett)
Why the GOV.UK Design System team changed the input type for numbers (Technology in Government)
Using
<input type="text" inputmode="numeric" pattern="[0-9]*">
(instead of<input type="number"
) allows for a degree of separation between how the user enters data (“input mode”), what the browser expects the user input to contain (type equals number), and potentially how it tries to validate it.
An interesting post from the UK Government listing a host of usability and accessibility problems arising from using <input type="number">
.
Now that browser support for the inputmode
attribute is sufficient, they have moved to <input type="text" inputmode="numeric">
.
I trust GOV.UK’s opinion and think I’ll follow suit.
Design Better Forms (UX Collective)
As Andrew Coyle says, “Life is short. No one wants to fill out a form.”. Here, he presents a number of form design tips to make the user experience more bearable and increase completion rates.
Styling a Select Like It’s 2019 (Filament Group, Inc.)
Recently, we’d seen some articles suggest that things haven’t changed a great deal with select's styling limitations, but I decided to return to the problem and tinker with it myself to be sure. As it turns out, a reasonable set of styles can create a consistent and attractive select across new browsers, while remaining just fine in older ones too.
Here’s a breakthrough in the always-frustrating field of styling form elements. Scott Jehl of Filament Group introduces a new technique for styling the select
element in a modern way without the need for a parent element, pseudo-elements, or javascript. Thanks, Scott!
(via @scottjehl)
See all tags.