Visitar URL original
USWDS - Accordion: Extending accordion to allow for start/end icon alignment by jonathanbobel · Pull Request #6789 · uswds/uswds · GitHub
Skip to content

USWDS - Accordion: Extending accordion to allow for start/end icon alignment - #6789

Merged
jonathanbobel merged 8 commits into
developfrom
feat/6784-introduce-left-justified-icon-accordion
Aug 14, 2026
Merged

jonathanbobel merged 8 commits into
developfrom
feat/6784-introduce-left-justified-icon-accordion

Conversation

@jonathanbobel

@jonathanbobel jonathanbobel commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

USWDS - Accordion: Extending accordion to allow for start/end icon alignment

Summary

Extended the expand/collapse icon to default to the start, or "left" side in the accordion button so magnification and zoom users can more easily discover interactive accordion controls, while keeping "end" (right-aligned) icons as an option.

Breaking change

This is not a breaking change.

Related issue

Closes #6784

Related pull requests

Related discussion: Component proposal in #6483 (VA user research on left-justified accordion controls).
Documentation for the new modifier and $theme-accordion-icon-position has a follow-up branch

Problem statement

Desired: Accordion expand/collapse controls are discoverable and understandable for users viewing content at high magnification or zoom levels, including screen magnification users and users who pinch-zoom or use programmatic zoom (e.g. Ctrl/Cmd + +).

Actual: Accordion expand/collapse icons are fixed on the right/end side of the button. When users zoom in, the control can fall outside the visible viewport or be harder to associate with the accordion heading, so users may not realize the accordion is interactive and important content can remain hidden.

Consequence: This disproportionately affects low-vision users who rely on screen magnification, but it also affects anyone zoomed in on mobile or desktop when content does not reflow as expected. VA user research (February 2026, referenced in #6483) found that left/start-justified expand/collapse controls improved discoverability: all screen magnification users in that study could identify the accordion as interactive. Left/start-justified controls were also reported as understandable and usable across broader user groups, not only magnification tool users.

Solution

This PR adds an easy, supported way to default to the left/start side of the accordion trigger, while keeping the option for a user to set the icon to the right/end.

  1. Theme setting: $theme-accordion-icon-position (default "start") sets icon placement globally. Use "end" to keep the previous right-side (LTR) look.
  2. Modifier classes: .usa-accordion--icon-start and .usa-accordion--icon-end support per-instance placement in markup.
  3. Refactored styles: Shared mixins use logical properties (padding-inline-*, text-align: start, RTL background-position flips) so start and end variants stay visually and accessibly consistent in LTR and RTL.
  4. Storybook: Default stories use the start-side icon. Added an IconEnd story and content fixture for the previous end-side placement.

No JavaScript or markup structure changes were required; open/closed icon behavior continues to be driven by existing aria-expanded styles.

Why this approach: A theme token plus modifier classes matches USWDS patterns and uses logical start / end so placement follows writing direction. Default is now "start" (left in LTR, right in RTL), which matches VA research on left-justified controls. Teams that want the previous look can set $theme-accordion-icon-position: "end" or add .usa-accordion--icon-end.

Limitations: Placement is limited to "start" and "end". Teams should still verify layout at common zoom levels and with screen magnification tools in their target browsers, including RTL (dir="rtl").

Major changes

  • Added $theme-accordion-icon-position to _settings-components.scss (default: "start")
  • Refactored accordion button padding and background positioning into shared mixins using logical properties
  • Updated high contrast mode ::before icon positioning to respect icon side
  • Added .usa-accordion--icon-start and .usa-accordion--icon-end modifiers
  • Added usa-accordion~icon-end.json content and IconEnd Storybook story
  • Set accordion button text-align: start so heading text follows RTL with the icon and body copy

Testing and review

  • Run npm test and confirm all tests pass

Manual verification

Run npm start

  1. Default / IconEnd stories: Confirm default shows the icon on start (left in LTR); IconEnd shows the previous end-side placement with correct spacing
  2. RTL: Set dir="rtl" and confirm heading text, body copy, and icon all flip with start/end
  3. Zoom / magnification: At 200%+ browser zoom (and with OS screen magnification if available), confirm the expand/collapse icon remains visible and clearly associated with the accordion heading
  4. Interaction: Expand/collapse panels; confirm open/closed icon states update correctly
  5. Hover and forced-colors: Verify hover states and high contrast icon placement on both sides
  6. Bordered variant: Confirm bordered accordion follows the theme default unless a modifier is applied

Additional notes

Banner and header accordions are unchanged. The “Here’s how you know” control and header navigation keep their existing icon placement.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

✅ All commits on this PR have a verified signature. Thanks!

@ethangardner ethangardner left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this. I know a lot of research and discussion went into this decision. For documentation purposes, can you update the PR body so it reflects that the new default is icon-start (left) in the "Solution" heading and indicate that this is a breaking change. It still has default right and non-breaking in the PR body.

Since our last release, I added a good deal of test coverage for branching logic in *.spec.js files using the sass-true package, and I think it would be good to do the same here for the branching logic.

There are also some comments inline with the files as well. The biggest one is the defensive coding to protect against anyone who tries to add a usa-accordion--icon-start class to the nav or banner.

@ethangardner ethangardner added this to the uswds 3.14.0 - Aug 2026 milestone Aug 12, 2026
@jonathanbobel jonathanbobel changed the title USWDS - Accordion: Extending accordion to allow for left icon alignment USWDS - Accordion: Extending accordion to allow for start/end icon alignment Aug 13, 2026

@ethangardner ethangardner left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for addressing the feedback. This looks really good! You did great on the handling of the rtl treatment as well.

@chandracarney chandracarney moved this from Triage to Fed Final Review in USWDS Core Project Data Aug 14, 2026

@chandracarney chandracarney left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this, looks great! Let's add a short note about excluding banner in the PR comment.

I added banner exclusion to the main issue #6784 just now, as I noticed it was missing there as well.

@jonathanbobel
jonathanbobel merged commit 5e82f20 into develop Aug 14, 2026
7 checks passed
@ethangardner
ethangardner deleted the feat/6784-introduce-left-justified-icon-accordion branch August 14, 2026 15:32
@chandracarney chandracarney moved this from Fed Final Review to Done in USWDS Core Project Data Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

USWDS - Accordion: Introduce a left-justified expand/collapse control

3 participants