Skip to content

Conversation

@owenatgov
Copy link
Contributor

Adds examples to button for:

  • forced hover state of all variants
  • disabled state of all variants
  • forced focus state, only of the default button since it's the same for all variants

Part of #6257 although will not resolve it

We previously remvoed a lot of these examples in #6091 however the design system designers expressed that it'd be useful to see these examples at a glance, in particular the different colours.

This could be remedied more completely by some sort of states API as detailed in #6257 (comment), but this PR does the job for now

@owenatgov owenatgov requested a review from a team October 6, 2025 08:47
@github-actions
Copy link

github-actions bot commented Oct 6, 2025

Rendered HTML changes to npm package

diff --git a/packages/govuk-frontend/dist/govuk/components/button/template-default-hover-state.html b/packages/govuk-frontend/dist/govuk/components/button/template-default-hover-state.html
new file mode 100644
index 000000000..2a137afe8
--- /dev/null
+++ b/packages/govuk-frontend/dist/govuk/components/button/template-default-hover-state.html
@@ -0,0 +1,3 @@
+<button type="submit" class="govuk-button :hover" data-module="govuk-button">
+  Save and continue
+</button>
diff --git a/packages/govuk-frontend/dist/govuk/components/button/template-focus-state.html b/packages/govuk-frontend/dist/govuk/components/button/template-focus-state.html
new file mode 100644
index 000000000..4c1a45798
--- /dev/null
+++ b/packages/govuk-frontend/dist/govuk/components/button/template-focus-state.html
@@ -0,0 +1,3 @@
+<button type="submit" class="govuk-button :focus" data-module="govuk-button">
+  Save and continue
+</button>
diff --git a/packages/govuk-frontend/dist/govuk/components/button/template-inverse-disabled.html b/packages/govuk-frontend/dist/govuk/components/button/template-inverse-disabled.html
new file mode 100644
index 000000000..1ef7c2240
--- /dev/null
+++ b/packages/govuk-frontend/dist/govuk/components/button/template-inverse-disabled.html
@@ -0,0 +1,3 @@
+<button type="submit" name="Inverse" disabled aria-disabled="true" class="govuk-button govuk-button--inverse" data-module="govuk-button">
+  Inverse button
+</button>
diff --git a/packages/govuk-frontend/dist/govuk/components/button/template-inverse-hover-state.html b/packages/govuk-frontend/dist/govuk/components/button/template-inverse-hover-state.html
new file mode 100644
index 000000000..d1c078612
--- /dev/null
+++ b/packages/govuk-frontend/dist/govuk/components/button/template-inverse-hover-state.html
@@ -0,0 +1,3 @@
+<button type="submit" name="Inverse" class="govuk-button govuk-button--inverse :hover" data-module="govuk-button">
+  Inverse button
+</button>
diff --git a/packages/govuk-frontend/dist/govuk/components/button/template-secondary-disabled.html b/packages/govuk-frontend/dist/govuk/components/button/template-secondary-disabled.html
new file mode 100644
index 000000000..11a66b36f
--- /dev/null
+++ b/packages/govuk-frontend/dist/govuk/components/button/template-secondary-disabled.html
@@ -0,0 +1,3 @@
+<button type="submit" name="secondary" disabled aria-disabled="true" class="govuk-button govuk-button--secondary" data-module="govuk-button">
+  Secondary button disabled
+</button>
diff --git a/packages/govuk-frontend/dist/govuk/components/button/template-secondary-hover-state.html b/packages/govuk-frontend/dist/govuk/components/button/template-secondary-hover-state.html
new file mode 100644
index 000000000..f78faf1d0
--- /dev/null
+++ b/packages/govuk-frontend/dist/govuk/components/button/template-secondary-hover-state.html
@@ -0,0 +1,3 @@
+<button type="submit" name="secondary" class="govuk-button govuk-button--secondary :hover" data-module="govuk-button">
+  Secondary button
+</button>
diff --git a/packages/govuk-frontend/dist/govuk/components/button/template-warning-disabled.html b/packages/govuk-frontend/dist/govuk/components/button/template-warning-disabled.html
new file mode 100644
index 000000000..691243b11
--- /dev/null
+++ b/packages/govuk-frontend/dist/govuk/components/button/template-warning-disabled.html
@@ -0,0 +1,3 @@
+<button type="submit" name="warning" disabled aria-disabled="true" class="govuk-button govuk-button--warning" data-module="govuk-button">
+  Warning button disabled
+</button>
diff --git a/packages/govuk-frontend/dist/govuk/components/button/template-warning-hover-state.html b/packages/govuk-frontend/dist/govuk/components/button/template-warning-hover-state.html
new file mode 100644
index 000000000..aae327d82
--- /dev/null
+++ b/packages/govuk-frontend/dist/govuk/components/button/template-warning-hover-state.html
@@ -0,0 +1,3 @@
+<button type="submit" name="Warning" class="govuk-button govuk-button--warning :hover" data-module="govuk-button">
+  Warning button
+</button>

Action run for b027fa4

@github-actions
Copy link

github-actions bot commented Oct 6, 2025

Other changes to npm package

diff --git a/packages/govuk-frontend/dist/govuk/components/button/fixtures.json b/packages/govuk-frontend/dist/govuk/components/button/fixtures.json
index 09948f778..fe366a789 100644
--- a/packages/govuk-frontend/dist/govuk/components/button/fixtures.json
+++ b/packages/govuk-frontend/dist/govuk/components/button/fixtures.json
@@ -12,6 +12,30 @@
             "screenshot": true,
             "html": "<button type=\"submit\" class=\"govuk-button\" data-module=\"govuk-button\">\n  Save and continue\n</button>"
         },
+        {
+            "name": "default hover state",
+            "options": {
+                "text": "Save and continue",
+                "classes": ":hover"
+            },
+            "hidden": false,
+            "description": "",
+            "pageTemplateOptions": {},
+            "screenshot": false,
+            "html": "<button type=\"submit\" class=\"govuk-button :hover\" data-module=\"govuk-button\">\n  Save and continue\n</button>"
+        },
+        {
+            "name": "focus state",
+            "options": {
+                "text": "Save and continue",
+                "classes": ":focus"
+            },
+            "hidden": false,
+            "description": "",
+            "pageTemplateOptions": {},
+            "screenshot": false,
+            "html": "<button type=\"submit\" class=\"govuk-button :focus\" data-module=\"govuk-button\">\n  Save and continue\n</button>"
+        },
         {
             "name": "disabled",
             "options": {
@@ -74,6 +98,33 @@
             "screenshot": false,
             "html": "<button type=\"submit\" name=\"secondary\" class=\"govuk-button govuk-button--secondary\" data-module=\"govuk-button\">\n  Secondary button\n</button>"
         },
+        {
+            "name": "secondary hover state",
+            "options": {
+                "name": "secondary",
+                "text": "Secondary button",
+                "classes": "govuk-button--secondary :hover"
+            },
+            "hidden": false,
+            "description": "A button for secondary actions",
+            "pageTemplateOptions": {},
+            "screenshot": false,
+            "html": "<button type=\"submit\" name=\"secondary\" class=\"govuk-button govuk-button--secondary :hover\" data-module=\"govuk-button\">\n  Secondary button\n</button>"
+        },
+        {
+            "name": "secondary disabled",
+            "options": {
+                "name": "secondary",
+                "text": "Secondary button disabled",
+                "classes": "govuk-button--secondary",
+                "disabled": true
+            },
+            "hidden": false,
+            "description": "",
+            "pageTemplateOptions": {},
+            "screenshot": false,
+            "html": "<button type=\"submit\" name=\"secondary\" disabled aria-disabled=\"true\" class=\"govuk-button govuk-button--secondary\" data-module=\"govuk-button\">\n  Secondary button disabled\n</button>"
+        },
         {
             "name": "warning",
             "options": {
@@ -87,6 +138,33 @@
             "screenshot": false,
             "html": "<button type=\"submit\" name=\"Warning\" class=\"govuk-button govuk-button--warning\" data-module=\"govuk-button\">\n  Warning button\n</button>"
         },
+        {
+            "name": "warning hover state",
+            "options": {
+                "name": "Warning",
+                "text": "Warning button",
+                "classes": "govuk-button--warning :hover"
+            },
+            "hidden": false,
+            "description": "A button for actions that need a warning",
+            "pageTemplateOptions": {},
+            "screenshot": false,
+            "html": "<button type=\"submit\" name=\"Warning\" class=\"govuk-button govuk-button--warning :hover\" data-module=\"govuk-button\">\n  Warning button\n</button>"
+        },
+        {
+            "name": "warning disabled",
+            "options": {
+                "name": "warning",
+                "text": "Warning button disabled",
+                "classes": "govuk-button--warning",
+                "disabled": true
+            },
+            "hidden": false,
+            "description": "",
+            "pageTemplateOptions": {},
+            "screenshot": false,
+            "html": "<button type=\"submit\" name=\"warning\" disabled aria-disabled=\"true\" class=\"govuk-button govuk-button--warning\" data-module=\"govuk-button\">\n  Warning button disabled\n</button>"
+        },
         {
             "name": "inverse",
             "options": {
@@ -102,6 +180,37 @@
             "screenshot": true,
             "html": "<button type=\"submit\" name=\"Inverse\" class=\"govuk-button govuk-button--inverse\" data-module=\"govuk-button\">\n  Inverse button\n</button>"
         },
+        {
+            "name": "inverse hover state",
+            "options": {
+                "name": "Inverse",
+                "text": "Inverse button",
+                "classes": "govuk-button--inverse :hover"
+            },
+            "hidden": false,
+            "description": "A button that appears on dark backgrounds",
+            "pageTemplateOptions": {
+                "bodyClasses": "app-template__body--inverse"
+            },
+            "screenshot": false,
+            "html": "<button type=\"submit\" name=\"Inverse\" class=\"govuk-button govuk-button--inverse :hover\" data-module=\"govuk-button\">\n  Inverse button\n</button>"
+        },
+        {
+            "name": "inverse disabled",
+            "options": {
+                "name": "Inverse",
+                "text": "Inverse button",
+                "classes": "govuk-button--inverse",
+                "disabled": true
+            },
+            "hidden": false,
+            "description": "A button that appears on dark backgrounds",
+            "pageTemplateOptions": {
+                "bodyClasses": "app-template__body--inverse"
+            },
+            "screenshot": false,
+            "html": "<button type=\"submit\" name=\"Inverse\" disabled aria-disabled=\"true\" class=\"govuk-button govuk-button--inverse\" data-module=\"govuk-button\">\n  Inverse button\n</button>"
+        },
         {
             "name": "attributes",
             "options": {

Action run for b027fa4

@github-actions
Copy link

github-actions bot commented Oct 6, 2025

📋 Stats

No changes to any distributed file sizes!


Action run for b027fa4

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-6309 October 7, 2025 11:19 Inactive
Copy link
Member

@romaricpascal romaricpascal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good for the added states, should the :active state be on there as well?

Wondering also if we should have the focus styles on there as well to see if there's any styles for the variant leaking in the focus style when they shouldn't.

Same could be said for having combinations (:hover + :active, :focus + :hover, :focus + :hover + :active) but that starts to be a lot 😓

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants