Skip to content

USWDS - Button group: align unstyled buttons - #4812

Merged
thisisdano merged 1 commit into
developfrom
al-button-group-align
Jul 5, 2022
Merged

thisisdano merged 1 commit into
developfrom
al-button-group-align

Conversation

@amyleadem

@amyleadem amyleadem commented Jun 14, 2022 •

Copy link
Copy Markdown
Contributor

Description

Closes: #4327

Preview link: Button group stories

Problem

When used inside a button group component, the unstyled button type aligns at the top of the group element.

Before:

image

Solution

Because the button group is built with flexbox, we can center the button's vertical alignment. This should consistently produce the desired alignment inside button groups.

After:

image

Testing

  1. Open the button group stories and use web inspector to replace the default usa-button-group html with the sample markup below.
  2. Note the centered vertical alignment of the unstyled Bar button

It is also worth thinking through if centered vertical alignment would cause unintended ill-effects.

<ul class="usa-button-group">
  <li class="usa-button-group__item">
    <a href="javascript:void(0);" class="usa-button">Back</a>
  </li>
  <li class="usa-button-group__item">
    <button class="usa-button">Default</button>
  </li>
  <li class="usa-button-group__item">
    <button class="usa-button usa-button--hover">Hover</button>
  </li>
  <li class="usa-button-group__item">
    <button class="usa-button usa-button--active">Active</button>
  </li>
  <li class="usa-button-group__item">
    <button class="usa-button usa-focus">Focus</button>
  </li>
   <li class="usa-button-group__item">
    <button class="usa-button usa-button--disabled">Disabled</button>
  </li>
  <li class="usa-button-group__item">
    <button class="usa-button usa-button--unstyled">Bar</button>
  </li>
</ul>

Additional information

Before you hit Submit, make sure you’ve done whichever of these applies to you:

  • Follow the 18F Front End Coding Style Guide and Accessibility Guide.
  • Run npm test and make sure the tests for the files you have changed have passed.
  • Run your code through HTML_CodeSniffer and make sure it’s error free.
  • Title your pull request using this format: [Website] - [UI component]: Brief statement describing what this pull request solves.

@amyleadem
amyleadem marked this pull request as ready for review June 14, 2022 23:13
@amyleadem
amyleadem requested review from mahoneycm and mejiaj June 14, 2022 23:13
@mejiaj
mejiaj requested a review from thisisdano June 17, 2022 16:18
@mejiaj mejiaj assigned thisisdano and unassigned mejiaj Jun 17, 2022
@thisisdano
thisisdano merged commit 9f3daff into develop Jul 5, 2022
@thisisdano
thisisdano deleted the al-button-group-align branch July 5, 2022 16:32
@thisisdano thisisdano mentioned this pull request Aug 5, 2022
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

Successfully merging this pull request may close these issues.

Unstyled buttons in button groups are not baseline-aligned with other buttons

3 participants