Skip to content

Commit

Permalink
Filter panel: Force checkbox/radio background
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
csutter committed Sep 20, 2024
1 parent 381b0f1 commit d3712fa
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/assets/stylesheets/components/_filter-panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
background-color: govuk-colour("light-grey");
padding: 0 govuk-spacing(3);
margin-top: govuk-spacing(2);

// 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 https://github.com/alphagov/govuk-frontend/issues/1625).
.govuk-checkboxes__label, .govuk-radios__label {
&::before {
background-color: govuk-colour('white');
}
}
}

.app-c-filter-panel__header {
Expand Down
38 changes: 38 additions & 0 deletions app/views/components/docs/filter_panel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,44 @@ examples:
} do %>
<span>filter section content</span>
<% end %>
with_radios_and_checkboxes:
description: |
Overrides default styles of GOV.UK Frontend radios and checkboxes to ensure they have a white
background despite being inside a grey panel.
data:
button_text: Filter with radios and checkboxes
open: true
block: |
<div class="govuk-!-padding-4">
<%= render "govuk_publishing_components/components/radio", {
heading: "Radios",
name: "radio",
small: true,
items: [
{ value: "1", text: "Radio 1" },
{ value: "2", text: "Radio 2", checked: true }
]
} %>
<%= render "govuk_publishing_components/components/checkboxes", {
name: "checkbox",
heading: "Checkboxes",
small: true,
items: [
{
label: "Red",
value: "red"
},
{
label: "Green",
value: "green"
},
{
label: "Blue",
value: "blue"
}
]
} %>
</div>
with_margin_bottom:
description: |
Allows the spacing at the bottom of the component to be adjusted.
Expand Down

0 comments on commit d3712fa

Please sign in to comment.