Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why do checkboxes and radios have transparent backgrounds? #1625

Open
Tracked by #5185
davehaigh opened this issue Oct 30, 2019 · 5 comments
Open
Tracked by #5185

Why do checkboxes and radios have transparent backgrounds? #1625

davehaigh opened this issue Oct 30, 2019 · 5 comments
Labels
checkboxes documentation User requests new documentation or improvements to existing documentation 🕔 hours A well understood issue which we expect to take less than a day to resolve. 🔍 investigation Question: decision-making User queries product decisions radios

Comments

@davehaigh
Copy link

davehaigh commented Oct 30, 2019

The following came from a question I asked on the design system slack channel.
https://ukgovernmentdigital.slack.com/archives/C6DMEH5R6/p1572279335253200

TLDR: checkboxes and radios have transparent backgrounds. This means they don't stand out visually against non white panels as text input elements do.

From thread:

does anyone know why the checkboxes (and I assume radio buttons) have transparent backgrounds? Rather than a white background (which would probably be the default browser rendering of a standard checkbox).
GOV checkbox (with transparent background):
image
Default checkbox (without GOV styling):
image

Anon 1:
I suspect that’s because they’re custom rendered rather than native checkboxes, and we want to support users who change their text and background colours.

11 replies

Anon 2:
Hi Dave,
This decision pre-dates the design system so I'll need to do a bit of digging to see if we can find out why - but my guess is something along the lines of what Anon 1 said. Will come back to you.
Have you seen any problems around this, or are you just wondering?
After some investigation - it appears that his is the pertinent commit: alphagov/govuk_elements@4972b81

Dave Haigh
I am looking at using small checkboxes as a filter for a list. The filters are located on a light grey panel (similar to the call to action blocks on GOV.UK guidance pages). As you can see in the screenshot the checkbox doesn’t stand out well as the background is transparent.

Im not sure on the answer to this but… should the scenario be:

  • If user HAS NOT specified any browser background colour then they should be white;
  • Else if user HAS a specified background colour in certain modes then they should be either transparent or that colour (when in that mode)
  1. Is the above correct?
  2. Is it possible?
    3.Also, some other elements do not respect user specified background colours such as text inputs (they’re always white). Why are only the checks and radios transparent?

i’ve specified my background colour to be red (in any mode) in this screenshot:
image

Anon 3
I don’t really have a good answer for you other than that the radios and checkboxes in the Design System are based on those introduced in Elements back in 2016 by people that no longer work here. As Anon 2 said, we don’t have the context of every historical decision. We could definitely look at changing that behaviour, but we’d need to test thoroughly to make sure they still work in all of these sorts of scenarios.

@NickColley NickColley added the awaiting triage Needs triaging by team label Oct 30, 2019
@jamesmking
Copy link

The current styles allow us to change the colour of the entire checkbox and radio button easily. We have a couple of instances across our service where we have a white checkbox on a solid colour. If the checkbox had a solid white background here, then we wouldn’t see the tick.
Screenshot 2019-10-30 at 10 10 31

@NickColley
Copy link
Contributor

For some more context this decision was made in the legacy GOV.UK Elements project: alphagov/govuk_elements#296

I've added awaiting-triage for us to look into this as a team.

@NickColley NickColley added 🕔 hours A well understood issue which we expect to take less than a day to resolve. Priority: low labels Oct 30, 2019
@NickColley
Copy link
Contributor

We want to do an investigation into how this would impact users who change their colours, so we're going to put aside an hour to look into this, thanks for raising @davehaigh :)

@NickColley NickColley added Question: decision-making User queries product decisions and removed awaiting triage Needs triaging by team labels Oct 30, 2019
@hannalaakso hannalaakso added the documentation User requests new documentation or improvements to existing documentation label Mar 30, 2020
@robpataki
Copy link

Hello @NickColley. I wonder if there is any further development on this topic. I find it strange that most form controls (text input, select and text area) have a defined white background, but checkboxes and radios don't. I gather there must be reasons why radios and checkboxes haven't been given the same background colour to provide consistency in the UI.

It would be great to better understand what the reasons are, and if this is something that is supported by user research or other practical reasons. Any insight would be greatly appreciated.

@querkmachine
Copy link
Member

@robpataki Hi Rob,

A quick correction: We don't actually define the white background on text inputs or textareas; these are the user agent styles supplied by the browser. We originally did this because explicitly defining colours (even to make them transparent) used to trigger an accessibility issue in Firefox when using forced colour modes, although this seems to have been fixed since.

Conversely, we explicitly define black text and a white background on <select> inputs because the user agent styles in some browsers are lower contrast than desired.

Unfortunately when it comes to radios and checkboxes, my guess is as good as the commit message in the original post: it's so users who customise their text and background colours get matching styles.

csutter added a commit to alphagov/finder-frontend that referenced this issue Sep 20, 2024
GOV.UK Frontend radio and checkboxes are rendered with a transparent
background, which makes them look wrong on this component's grey
background. This is intentional in GOV.UK Frontend and unlikely to
change (see alphagov/govuk-frontend#1625).
csutter added a commit to alphagov/finder-frontend that referenced this issue Sep 20, 2024
GOV.UK Frontend radio and checkboxes are rendered with a transparent
background, which makes them look wrong on this component's grey
background. This is intentional in GOV.UK Frontend and unlikely to
change (see alphagov/govuk-frontend#1625).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
checkboxes documentation User requests new documentation or improvements to existing documentation 🕔 hours A well understood issue which we expect to take less than a day to resolve. 🔍 investigation Question: decision-making User queries product decisions radios
Projects
None yet
Development

No branches or pull requests

8 participants