[SPIKE] Set media overrides in functional colours map; support @media (prefers-contrast: more)#6788
Draft
[SPIKE] Set media overrides in functional colours map; support @media (prefers-contrast: more)#6788
@media (prefers-contrast: more)#6788Conversation
…-colour` mixin The mixin only outputs a constant `color` declaration, so we can replace its calls with `color: govuk-colour(text)`. Adds a few `stylelint-disable order/order-properties` comments, as the rule was ungrouping margin declarations and `@include govuk-responsive-spacing` calls
As all it does is output a constant CSS declaration, we can ask users to write that `color` declaration instead of calling the mixin. Co-authored-by: seaemsi <50173207+seaemsi@users.noreply.github.com>
Stylesheets changes to npm packagediff --git a/packages/govuk-frontend/dist/govuk/govuk-frontend.min.css b/packages/govuk-frontend/dist/govuk/govuk-frontend.min.css
index d4b9533e4..470b83b65 100644
--- a/packages/govuk-frontend/dist/govuk/govuk-frontend.min.css
+++ b/packages/govuk-frontend/dist/govuk/govuk-frontend.min.css
@@ -27,9 +27,16 @@
--govuk-surface-border-colour: #8eb8dc
}
-@media print {
+@media (print) {
+ :root {
+ --govuk-text-colour: #000
+ }
+}
+
+@media (prefers-contrast:more) {
:root {
- --govuk-text-colour: var(--govuk-print-text-colour, #000)
+ --govuk-text-colour: #000;
+ --govuk-border-colour: #858686
}
}
Action run for 377390f |
Other changes to npm packagediff --git a/packages/govuk-frontend/dist/govuk/custom-properties/_functional-colours.scss b/packages/govuk-frontend/dist/govuk/custom-properties/_functional-colours.scss
index 261a800dd..a2b2271e5 100644
--- a/packages/govuk-frontend/dist/govuk/custom-properties/_functional-colours.scss
+++ b/packages/govuk-frontend/dist/govuk/custom-properties/_functional-colours.scss
@@ -1,3 +1,6 @@
+@use "sass:map";
+@use "sass:meta";
+
@import "../settings/custom-properties";
@import "../settings/colours-functional";
@import "../tools/exports";
@@ -9,11 +12,14 @@
@if $govuk-output-custom-properties {
@each $name, $value in $govuk-functional-colours {
--govuk-#{$name}-colour: #{_govuk-resolve-colour($value)};
- }
- @media print {
- // Use 'true black' to avoid printers using colour ink to print body text
- --govuk-text-colour: #{govuk-functional-colour("print-text")};
+ @if meta.type-of($value) == "map" and map.has-key($value, "media") {
+ @each $query, $media-value in map.get($value, "media") {
+ @media (#{$query}) {
+ --govuk-#{$name}-colour: #{_govuk-resolve-colour($media-value)};
+ }
+ }
+ }
}
}
}
diff --git a/packages/govuk-frontend/dist/govuk/settings/_colours-functional.scss b/packages/govuk-frontend/dist/govuk/settings/_colours-functional.scss
index 24baac277..81492e971 100644
--- a/packages/govuk-frontend/dist/govuk/settings/_colours-functional.scss
+++ b/packages/govuk-frontend/dist/govuk/settings/_colours-functional.scss
@@ -19,7 +19,11 @@ $govuk-default-functional-colours: (
name: "blue"
),
"text": (
- name: "black"
+ name: "black",
+ media: (
+ print: #000000,
+ "prefers-contrast: more": #000000
+ )
),
// The background colour of the template. This is intended to be the same
// as `surface-background` for the purposes of making the Footer and Cookie
@@ -59,7 +63,13 @@ $govuk-default-functional-colours: (
// Used in for example borders, separators, rules and keylines.
"border": (
name: "black",
- variant: "tint-80"
+ variant: "tint-80",
+ media: (
+ "prefers-contrast: more": (
+ name: "black",
+ variant: "tint-50"
+ )
+ )
),
// Used for form inputs and controls
"input-border": (
Action run for 377390f |
📋 StatsFile sizes
No changes to module sizes. Action run for 377390f |
4 tasks
edb0130 to
8ac4b45
Compare
Base automatically changed from
print-text-through-custom-properties
to
main
February 27, 2026 11:16
| name: "black" | ||
| name: "black", | ||
| media: ( | ||
| print: #000000, |
Member
There was a problem hiding this comment.
suggestion If we modify _govuk-resolve-colour we may be able to define it as 'print-text' rather than #000000 until we remove print-text from the codebase.
This was referenced Feb 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Spiking a couple of things we could do, building on top of the work in #6427:
functional-coloursmap, making them configurable#000and to darken the border colour from a 80% tint to a 50% tint of black if the"prefers-contrast: more"media query applies (this has recently been flagged as low contrast in border colour ratio with body-background is too low #6776)