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

Text colour for inverse button should use variable that indicates design intent #3918

Open
paulrobertlloyd opened this issue Jul 6, 2023 · 3 comments
Labels

Comments

@paulrobertlloyd
Copy link
Contributor

paulrobertlloyd commented Jul 6, 2023

Related component

Button component.

Version v4.7.0 introduced an inverse button modifier (yay!), but it's hard coded to use govuk-colour("blue"):

$govuk-inverse-button-text-colour: govuk-colour("blue");

However, it’s not clear if this is blue because govuk-brand-colour is blue, or because govuk-link-colour is blue. In most cases, this doesn't matter because backgrounds and links are both blue. But when the brand or link colours differ from the default, what should an inverse button look like? Should it:

  • Have a text colour that is the same as other links
  • Have a text colour that is the same as the background it sits on (essentially giving it a ‘see-through’ appearance)

Context

  • On the Mod Design System site, the inverse button shares the same colour as the background and the link colour, which are both #532a45:

    MoD masthead with inverse button
  • On X-GOVUK sites, the inverse button text colour is the same as the turquoise background (brand) colour (#2288aa), as links are Blue (#1d70b8):

    X-GOVUK masthead with inverse button

Alternatives

On the prototype masthead component, am considering whether to override the hardcoded Blue colour to share that of the masthead’s background: x-govuk/govuk-prototype-components#134

Additional information (if applicable)

Happy with whatever design decision the Design System team come up with, but the colour in the codebase should indicate the design intent behind the colour chosen for inverse buttons; either govuk-brand-colour or govuk-link-colour (but not govuk-colour("blue")).

@paulrobertlloyd paulrobertlloyd added awaiting triage Needs triaging by team feature request User requests a new feature labels Jul 6, 2023
@paulrobertlloyd
Copy link
Contributor Author

Accessibility consideration: the link text colour is (and should be) one that works with text on a white background. A brand colour is likely one that is chosen to work in large background areas and decorative borders, and may not have enough contrast when used for text. So I suspect the more robust choice is for the button text to share the colour of links.

@paulrobertlloyd paulrobertlloyd changed the title Text colour for inverse button should use colour variable that indicates design intent Text colour for inverse button should use variable that indicates design intent Jul 6, 2023
@querkmachine
Copy link
Member

Hmm, my concern is also that the brand colour has no guarantee of contrast when used against white—although the Notification Banner component appears to have already assumed it will, using $govuk-brand-colour on line 8 and hardcoding white text on top of it on line 33.

In my mind, we might want to do something like this:

  • Add a new global settings variable, named something like $govuk-inverse-text-colour, so we can stop hardcoding our new inverse modifiers as always being white.
  • Change $govuk-inverse-button-text-colour to be the same as $govuk-brand-colour by default.
  • Change $govuk-inverse-button-colour to be the same as $govuk-inverse-text-colour by default.
  • Change the above two variables to be publicly settable, as green start buttons already are, to account for any outlying situations.1

Does that sound like it'd work for the use cases described here?

Footnotes

  1. To contrive a circumstance. A team wants to keep the inverse text colour as white, as they use it on non-brand colours too (like black), but white does not provide suitable contrast with the brand colour, so they need to change one or both of the inverse button variables specifically.

@paulrobertlloyd
Copy link
Contributor Author

paulrobertlloyd commented Jul 7, 2023

To underline the current issue, inverse button text may not match your brand colours, and if that brand colour is lighter, the inverse text colour won’t be accessible when sat upon it:

UI with current hard coded colour values

I think you’re right; hard-coding any of these exiting component colour values to either $govuk-brand-colour or $govuk-link-colour, while that might make this less of an issue, it would still be a problem with certain combinations.

Giving these values defaults that can be overridden globally, as you propose, seems like a brilliant solution!

Playing with that idea, all the following possible outcomes would be possible:

UI with customisable colour values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants