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

Order of imports affects styling for checkboxes and radio labels #949

Open
mikemonteith opened this issue May 16, 2024 · 1 comment
Open

Comments

@mikemonteith
Copy link
Contributor

Bug Report

What is the issue?

We found an issue recently which was caused by <label class="nhsuk-label nhsuk-radios__label"> having display: block style.
It turns out that when importing individual sass components, the order of imports matters.

Correct styles:

@import 'node_modules/nhsuk-frontend/packages/components/label/label';
@import 'node_modules/nhsuk-frontend/packages/components/radios/radios';

Incorrect styles:

@import 'node_modules/nhsuk-frontend/packages/components/radios/radios';
@import 'node_modules/nhsuk-frontend/packages/components/label/label';

This is because the display rules in label.scss and radios.scss (and also checkboxes.scss) have the same specificity.

Solution

I think the specificity of the display rule for the label in radios.scss and checkboxes.scss should be increased so that it always takes precedence over the rule in labels.scss.

@edwardhorsford
Copy link
Contributor

Any idea what govuk-frontend does in this situation?

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

No branches or pull requests

2 participants