-
Notifications
You must be signed in to change notification settings - Fork 1k
USWDS - Radio and checkbox: Update label width to fit content #6192
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
USWDS - Radio and checkbox: Update label width to fit content #6192
Conversation
9693c82
to
45da634
Compare

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…ten-selectable-whitespace-in-radios
b9b2120
to
7dc27a2
Compare
We should consider checkboxes as well. :) |
42e7a73
to
a2fc5a0
Compare
@mahoneycm, based on our discussion on slack I decided to include checkboxes as part of this PR and the original ticket. I have fixed checkbox and updated testing steps. |

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks Cathy!
- No visual regressions
- Standard radio/checkbox cannot be triggered via whitespace
- Tile variants can be activated on their tile
- Styles make sense and are necessary for proper display
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks @cathybaptista
I completed the following checks in Firefox, Safari, and Chromium:
- Confirm the interaction area for both radio and checkboxes do not expand beyond the label content in default variant
- Confirm the interaction area for both radio and checkboxes fills the entire bordered area in the tile variant
- Confirm there are no visual regressions in any of the component variants
- Confirm that the checkboxes and radio buttons can still be interacted with as expected with both keyboard and mouse.
- Confirm the code changes make sense and meet USWDS standards
- Confirm the PR description is up-to-date and accurate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does what it says on the tin! Nice change
Summary
Changed display for radio buttons and checkbox to inline-block so that label fits its content. Added inherit to display for tile variant.
Breaking change
This is not a breaking change.
Related issue
Closes #6111
Related pull requests
Changelog
Preview link
Preview link radios:
Preview link checkboxes:
Problem statement
The selectable area adjacent to radio buttons and checkboxes was full width. This resulted in being able to select the button from an area far away from the component. This fix tightens the selectable area around these components.
NOTE
This issue also impacts checkbox. The same solution should apply to both components.
Solution
With display: block, the radio button's label occupies the full width of its parent container. With display: inline-block, the label will only occupy the space needed to fit its content.
Testing and review
Before opening this PR, make sure you’ve done whichever of these applies to you:
git pull origin [base branch]
to pull in the most recent updates from your base and check for merge conflicts. (Often, the base branch isdevelop
).npm run prettier:sass
to format any Sass updates.npm test
and confirm that all tests pass.