Skip to content

USWDS - Button: Collapse unstyled button width at small viewport sizes #5631

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 1 commit into from
Oct 3, 2024

Conversation

aduth
Copy link
Contributor

@aduth aduth commented Nov 21, 2023

Summary

Unstyled buttons no longer appear as full width at narrow viewport sizes. This brings the button into alignment with expectation of it being used in plain text contexts.

Breaking change

This may be considered a breaking change if someone had come to rely on the previous behavior. However, I'd argue that this behavior should have never been considered expected, and therefore fits the definition of a bug fix.

Related PR

Changelog PR

Preview link

Preview link: http://localhost:6006/?path=/story/components-button--unstyled

Before After
Screenshot 2023-11-21 at 9 04 46 AM Screenshot 2023-11-21 at 9 05 20 AM

Problem statement

We often use unstyled buttons as visually equivalent to a link. Therefore, we've encountered issues where the unstyled button occupies full width at mobile viewport sizes, causing line breaks in content.

See screenshots at 18F/identity-idp#9632 for example effect.

Solution

The solution proposed here resets the width: 100% applied to buttons by default at mobile viewport sizes, specifically for the unstyled button.

@mejiaj mejiaj added this to the uswds 3.8.0 milestone Nov 21, 2023
@brunerae brunerae added Needs: Discussion We need to discuss an approach to this issue Role: A11Y and removed Status: Triage labels Dec 7, 2023
@brunerae brunerae removed this from the uswds 3.8.0 milestone Dec 7, 2023
@aduth aduth force-pushed the aduth-unstyled-width branch from a02a674 to 0fa3d4d Compare May 31, 2024 18:32
@mejiaj
Copy link
Contributor

mejiaj commented Jul 25, 2024

For discussion

This is a legacy style. Should unstyled buttons be inline at small screen sizes too?

@mahoneycm
Copy link
Contributor

@mejiaj If the goal of these buttons are to replicate the look and feel of links, it makes sense to me that these would be inline.

From what I can tell in the codebase and our site, there shouldn't be any visual regressions. We used the unstyled button for the unstyled language selector but it appears to be unaffected by this change

@mahoneycm mahoneycm removed the Needs: Discussion We need to discuss an approach to this issue label Aug 27, 2024
@mahoneycm mahoneycm added this to the uswds 3.9.0 milestone Aug 27, 2024
@mahoneycm
Copy link
Contributor

Hey there @aduth

Thank you for contributing this work and providing the screenshots in the related issue you linked. It really helped to showcase the current state of the button and why we'd benefit from updating.

We've added this to the 3.9.0 and will review shortly!

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.

Thanks for this submission @aduth! The change looks good to me.

A few of notes for follow-on tasks with this PR:

  1. We should mark this as a breaking change in the PR description and release notes. This PR will change the default visual styles of "unstyled" buttons, and we should note that users should confirm the display of this variant in their projects.
  2. We should consider adding a note to the in the PR description, release notes, and/or button component page that the pattern of using buttons styled as links is currently under review with our accessibility and UX teams, and might not be a recommended practice.
  3. We should create follow-on issue that tests the target height of unstyled buttons to make sure they are compliant with WCAG 2.5.8.
  4. We should create a changelog for this PR. Update: I have drafted a PR for this changelog and have included a link to it in the PR description

Copy link
Contributor

@mejiaj mejiaj left a comment

Choose a reason for hiding this comment

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

A small, but impactful change. Thanks for the PR!

Wanted to note that the unstyled button is also used in language selector [develop].

@mejiaj mejiaj requested review from thisisdano and removed request for mahoneycm August 28, 2024 14:40
@mejiaj mejiaj removed their assignment Aug 28, 2024
@thisisdano
Copy link
Contributor

@amyleadem Can you create the issue you mentioned in your review?

We should create follow-on issue that tests the target height of unstyled buttons to make sure they are compliant with WCAG 2.5.8.

@amyleadem
Copy link
Contributor

Good catch @thisisdano! Opened #6091 to follow-up on the touch target size of the unstyled button variant.

@thisisdano thisisdano merged commit 13cdc61 into uswds:develop Oct 3, 2024
4 checks passed
@thisisdano thisisdano mentioned this pull request Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants