Tagged “affordance”
Building a Good Download… Button? by Eric Bailey
Question: when presenting users with a means of downloading a file, should you use the anchor
element or the button
element?
Answer: you should use the anchor
element.
Eric starts by quoting accessibility expert Scott O’Hara to explain why anchor is the appropriate element:
The debate about whether a button or link should be used to download a file is a bit silly, as the whole purpose of a link has always been to download content. HTML is a file, and like all other files, it needs to be retrieved from a server and downloaded before it can be presented to a user.
The confusion seems to come from developers getting super literal with the “links go places, buttons perform actions.” Yes, that is true, but links don’t actually go anywhere. They retrieve information and download it.
Long story short, the
download
attribute is unique to anchor links for a reason.download
augments the inherent functionality of the link retrieving data. It side steps the attempt to render the file in the browser and instead says, “You know what? I’m just going to save this for later…”
Eric follows up by suggesting that as designers and developers we should make the experience of interacting with a download link as good as possible. To that end:
- Ensure it looks like a link, i.e. underlined. You’re using a link (because it’s semantically appropriate) so now encourage the appropriate perceived affordances via conventional visual design for a link
- Use verb plus noun for the text. For example, Download fonts
- Include the file size (for example 34 MB) to give an indication of the download time
- Consider adding an indicator that the link does something other than take you to another place on your website. A downward-facing arrow is conventional
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.
Perceived affordances and the functionality mismatch (by Léonie Watson)
Léonie tackles the prickly subject of “element re-purposing” in web development. This post follows a fantastic Twitter exchange started by Lea Verou regarding whether the common visual design request for “adjacent but mututally exclusive buttons” should be built as radio buttons or using <button>
elements.
Using one element or set of elements (usually because of their functionality) and styling them to look like something else is a common pattern […but…] it creates a mismatch between the actions people expect they can take and the ones they actually can.
Relatedly, Lea has also gathered her post-discussion thoughts and decisions into a blog post What is the best way to mark up an exclusive button group? and shared a new button-group
web component!
Meanwhile, Léonie already has a theme-toggle web component on her personal website which demonstrates the use of buttons and aria-pressed
.
Thank you so much, Lea and Léonie.
Update July 19/7/22
I just had a twitter conversation with Adrian Roselli where I suggested that the reasons for developers considering radio inputs over buttons for Lea’s use case might be more nuanced than simply misunderstanding HTML. I’m not sure we agreed on that one in the end, however Adrian shared some helpful heuristics when choosing betweeen JS-powered buttons and forms:
A checkbox, radio button, select menu are meant to gather information. The submit button sends the form (whether get, post, or an AJAX call). A button (non-submit) causes a change on the page, such as toggling a control, showing or hiding something, etc. Different context/use.
I think it would help to think of form fields as for forms. Forms that users intentionally submit (no matter if processed client- or server-side). Forms that gather info. Buttons that have states (expanded, pressed, etc) are for manipulation of the current view.
Takeaways:
- Pick the HTML solution that is generally intended for your use case.
- Use a form if you’re gathering information but if you’re not, don’t. There will be exceptions like “filter forms” but that’s an edge case and most forms are not like that.
- Forms are ideally things that users intentionally submit, via a submit button. This helps rule out “clever forms” as an option.
- Use a button to cause a change on, or manipulate, the current page.
See all tags.