Skip to content

USWDS - Button Group: Improve appearance of buttons with wrapping text #5657

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

Merged
merged 4 commits into from
Feb 27, 2024

Conversation

mejiaj
Copy link
Contributor

@mejiaj mejiaj commented Dec 5, 2023

Important

This work is strictly to match button height in button-group. Changes in #5398 address the text alignment issue noted in #5657 (review).

Summary

Improved the appearance of button groups when button text wraps to multiple lines. Now, every button in the group will be the same height.

Extending work from #5324. Thanks @aduth!

Breaking change

This is not a breaking change.

Flex-wrap was explicitly added on mobile-lg, but it follows the current behavior of stacking on mobile and grouping above mobile-lg.

Additional information

With this implementation the button does not wrap on desktop sizes.

Before
image

After
image

As noted by @amyleadem in #5657 (review).

Related issue

N/A for this issue. Semi-related #5398.

Related pull requests

Extension of #5324.

Changelog PR: uswds/uswds-site#2498.

Preview link

Preview link: Button group text wrap preview →

Problem statement

Summarize the problem this PR solves in a clear and concise statement.

  1. Buttons in button group should match in height when one is bigger than the other.
  2. Currently, heights don't match.
  3. Visual quirk will make interfaces look broken.

Solution

Above mobile-lg breakpoint button groups will:

  1. Avoid wrapping (Default variant will still stack on mobile).
  2. List items will be stretched.
  3. Child buttons will take up the full height.

Testing and review

  1. Visit Button group text wrap preview →.
  2. Shrink screen size.
  3. Buttons in button group should be equal height.

- Stretch all button group items above mobile-lg breakpoint.
- Allow buttons to take full height.
- Add default variant example
@mejiaj mejiaj marked this pull request as ready for review December 5, 2023 22:08
@mejiaj mejiaj requested review from mahoneycm and amyleadem December 5, 2023 22:08
@mejiaj mejiaj added Type: Enhancement Context: Sass Issue is in Sass Role: Dev Development/engineering skills needed labels Dec 5, 2023
Copy link
Contributor

@mahoneycm mahoneycm 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! I noticed a visual bug with anchor elements we should address. This should be good to go after that 👍

Copy link
Contributor

@mahoneycm mahoneycm left a comment

Choose a reason for hiding this comment

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

  • Button group maintains equal heights at various sizes
  • Button group looks appropriate when one button has larger text content
  • Previous inconsistencies are resolved
  • No visual regressions

Copy link
Contributor

@amyleadem amyleadem left a comment

Choose a reason for hiding this comment

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

This is looking good. The usa-button elements inside the button group appear to be the same height regardless of their content, and the content is vertically centered.

Important

My only note is that I'd like to mark this as a potentially breaking change since the default button group will no longer wrap at "desktop" widths. I think it would be helpful to warn users to check their implementations.

Tests

After pulling in jm-enhancement-button-icons from #5398, I confirmed the following in Chrome, Safari, and Firefox:

  • Confirm that all elements in a button group are the same height regardless of content height
  • Confirm that text is vertically centered inside the usa-button elements (in both regular and button group)
    • Mobile view
    • Desktop view
  • Confirm that icons are vertically centered inside button group elements
  • Confirm that nowrap will not cause any unexpected breaks
  • Confirm that this works with both links and buttons

Screenshots

Mobile view

Before (mobile)
image

After (mobile)
image

Desktop view

Before (desktop)
image

After (desktop)
image

With icons

I also tested this with icons (to confirm compatibility with #5398) and it worked as expected:

image

image

@thisisdano thisisdano merged commit a4470d9 into develop Feb 27, 2024
@thisisdano thisisdano deleted the jm-segmented-button-text-wrap branch February 27, 2024 00:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Context: Sass Issue is in Sass Role: Dev Development/engineering skills needed
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants