Skip to content

feat(button): complete 2nd-gen migration#6254

Open
5t3ph wants to merge 14 commits intomainfrom
swc-1873/button
Open

feat(button): complete 2nd-gen migration#6254
5t3ph wants to merge 14 commits intomainfrom
swc-1873/button

Conversation

@5t3ph
Copy link
Copy Markdown
Contributor

@5t3ph 5t3ph commented May 8, 2026

Note to reviewers: This is the feature-branch merge. All individual phases were reviewed in separate, smaller PRs. This description provides the high-level summary; the migration plan has the full rationale and decision log.

The individual phase PRs (#6176, #6177, #6209, #6226, #6227, #6236, #6246) contain the detailed implementation history.


Description

Completes the 2nd-gen migration of sp-button to swc-button. The new component:

  • Renders a real internal <button> as the semantic control (host carries no button role or tab stop)
  • Adopts a clean core / swc split — ButtonBase in core owns accessible-name resolution, pending-label behavior, and attribute-forwarding logic so future button-like components (ActionButton, ClearButton, etc.) can reuse the semantic contract without inheriting swc-button's DOM or styling
  • Delivers full Spectrum 2 visual fidelity across all supported variant × fill-style × size × static-color combinations
  • Fixes the four tracked accessibility and visual bugs included in scope: SWC-459 (pending a11y), SWC-701 (label visibility), SWC-886 (truncated focus ring), SWC-1139 (static-white outline contrast)
  • Introduces a Vite plugin (vite-global-elements-css) that auto-generates global-button.css from button.css on every dev/build run, eliminating drift between the component and global-element styling

Breaking API changes (from 1st-gen)

1st-gen 2nd-gen
treatment="fill|outline" fill-style="fill|outline"
label (accessible name) accessible-label
no-wrap truncate
quiet (outline alias) removed; use fill-style="outline"
href, target, download, etc. removed; use native <a> with global button styles
Deprecated variant aliases (cta, overBackground, white, black) removed

See consumer-migration-guide.mdx for migration paths.

Deferred follow-up tickets

Ticket Item
SWC-2033 Cross-root ARIA support
SWC-2034 Form-associated submit / reset
SWC-2035 Host focus / blur compatibility parity
SWC-2036 genai and premium variants

Motivation and context

  • SWC-1873 (epic)
  • SWC-1884 (finalizing ticket)

Author's checklist

  • I have read the CONTRIBUTING and PULL_REQUESTS documents.
  • I have reviewed the Accessibility Practices for this feature, see: Aria Practices
  • I have added automated tests to cover my changes.
  • I have included a well-written changeset if my change needs to be published.
  • I have included updated documentation if my change required it.

Reviewer's checklist

  • Includes a GitHub issue with appropriate flag or Jira ticket number without a link
  • Includes thoughtfully written changeset if changes suggested include patch, minor, or major features
  • Automated tests cover all use cases and follow best practices for writing
  • Validated on all supported browsers

Manual review test cases

  • Smoke test the Storybook overview

    1. Open the Button component in 2nd-gen Storybook
    2. Verify the Playground story renders with default variant="primary" and all Storybook controls respond correctly
    3. Expect: no console errors, full visual rendering
  • Variants and fill styles

    1. View the Variants story and the Outline story
    2. Confirm accent and negative have no outline option (controls absent or disabled)
    3. Confirm primary and secondary render correctly in both fill and outline
    4. Expect: matches Figma spec; no unsupported combinations render
  • Static color

    1. View the Static Colors story
    2. Confirm static-color="white" outline button is displayed on a sufficiently dark background (SWC-1139)
    3. Expect: white outline button contrast is sufficient on hover
  • Pending state

    1. View the Pending story
    2. Toggle pending state, wait 1 second; confirm the spinner appears and the button label/icon fade out
    3. Confirm the pending button does not shrink when the label/icon fade (inline size locks)
    4. Expect: spinner visible after 1-second delay; button width stable
    5. Toggle pending state off
    6. Expect: button returns to non-pending visual with no delay
  • Truncation

    1. View the Truncate story
    2. Expect: text truncates with an ellipsis; focus ring is fully visible (not clipped)
  • Justified

    1. View the Justified story
    2. Expect: button stretches to fill its container width
  • Global button styles

    1. Open the global elements guide in Storybook (Guides > Customization > Global Element Styling)
    2. Confirm native <a> and <button> elements styled with .swc-Button classes match swc-button visually for shared combinations

Device review

  • Did it pass in Desktop?
  • Did it pass in (emulated) Mobile?
  • Did it pass in (emulated) iPad?

Accessibility testing checklist

  • Keyboard (required — document steps below)

    1. View the Accessibility story in 2nd-gen Storybook → Tab to "Save document" → Expect: button receives focus, focus ring is visible
    2. Tab to the icon-only "Add item" button → Expect: focus lands on the button; screen reader announces "Add item, button"
    3. Tab to the pending "Upload in-progress" button → Expect: button is included in tab order (not skipped); focus ring visible
    4. Enter or Space on the pending button → Expect: no activation; button stays focused
    5. View the States story → Tab through buttons → Expect: "Disabled" button is skipped; "Default" and "Pending" receive focus
  • Screen reader (required — document steps below)

    1. View the Accessibility story → Read each button → Expect: "Save document, button" / "Add item, button" / "Upload in-progress, dimmed button" (or platform equivalent); the swc-button host is NOT announced as a separate button
    2. View the States story → Read "Pending" button → Expect: button role plus unavailable/greyed-out state announced; accessible name includes "busy" or the resolved pending-label value
    3. Switch to browse mode (Command+Option+A to switch mode and Command+Option+Arrow keys to navigate), navigate to "Disabled" button → Expect: "Disabled, dimmed button" (or equivalent); cannot be activated
  • Windows High Contrast (SWC-459)

    1. Enable Windows High Contrast mode → View the States story → Wait 1 second for pending state to activate → Expect: pending button renders with disabled/unavailable colors
  • Reduced motion

    1. Enable prefers-reduced-motion: reduce → View the States or Pending story with pending toggle active → Wait 1 second → Expect: spinner is visible but animation is slowed per the preference

@5t3ph 5t3ph requested a review from a team as a code owner May 8, 2026 17:39
@5t3ph 5t3ph added Component:Button Includes ButtonBase, Clear Button, and Close Button Status:Ready for review PR ready for review or re-review. 2nd gen These issues or PRs map to our 2nd generation work to modernizing infrastructure. labels May 8, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 8, 2026

🦋 Changeset detected

Latest commit: 90022c3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 84 packages
Name Type
@adobe/spectrum-wc Minor
@spectrum-web-components/button Patch
@spectrum-web-components/action-bar Patch
@spectrum-web-components/action-button Patch
@spectrum-web-components/alert-banner Patch
@spectrum-web-components/alert-dialog Patch
@spectrum-web-components/button-group Patch
@spectrum-web-components/coachmark Patch
@spectrum-web-components/dialog Patch
@spectrum-web-components/infield-button Patch
@spectrum-web-components/picker-button Patch
@spectrum-web-components/picker Patch
@spectrum-web-components/search Patch
@spectrum-web-components/tags Patch
@spectrum-web-components/toast Patch
@spectrum-web-components/bundle Patch
@spectrum-web-components/vrt-compare Patch
@spectrum-web-components/action-group Patch
@spectrum-web-components/action-menu Patch
@spectrum-web-components/combobox Patch
@spectrum-web-components/contextual-help Patch
@spectrum-web-components/menu Patch
@spectrum-web-components/overlay Patch
@spectrum-web-components/tabs Patch
@spectrum-web-components/number-field Patch
@spectrum-web-components/custom-vars-viewer Patch
@spectrum-web-components/story-decorator Patch
documentation Patch
@spectrum-web-components/breadcrumbs Patch
@spectrum-web-components/popover Patch
@spectrum-web-components/textfield Patch
@spectrum-web-components/tooltip Patch
@spectrum-web-components/truncated Patch
@spectrum-web-components/top-nav Patch
@spectrum-web-components/slider Patch
@spectrum-web-components/card Patch
@spectrum-web-components/color-field Patch
@spectrum-web-components/accordion Patch
@spectrum-web-components/asset Patch
@spectrum-web-components/avatar Patch
@spectrum-web-components/badge Patch
@spectrum-web-components/checkbox Patch
@spectrum-web-components/clear-button Patch
@spectrum-web-components/close-button Patch
@spectrum-web-components/color-area Patch
@spectrum-web-components/color-handle Patch
@spectrum-web-components/color-loupe Patch
@spectrum-web-components/color-slider Patch
@spectrum-web-components/color-wheel Patch
@spectrum-web-components/divider Patch
@spectrum-web-components/dropzone Patch
@spectrum-web-components/field-group Patch
@spectrum-web-components/field-label Patch
@spectrum-web-components/help-text Patch
@spectrum-web-components/icon Patch
@spectrum-web-components/icons-ui Patch
@spectrum-web-components/icons-workflow Patch
@spectrum-web-components/icons Patch
@spectrum-web-components/iconset Patch
@spectrum-web-components/illustrated-message Patch
@spectrum-web-components/link Patch
@spectrum-web-components/meter Patch
@spectrum-web-components/modal Patch
@spectrum-web-components/progress-bar Patch
@spectrum-web-components/progress-circle Patch
@spectrum-web-components/radio Patch
@spectrum-web-components/sidenav Patch
@spectrum-web-components/split-view Patch
@spectrum-web-components/status-light Patch
@spectrum-web-components/swatch Patch
@spectrum-web-components/switch Patch
@spectrum-web-components/table Patch
@spectrum-web-components/thumbnail Patch
@spectrum-web-components/tray Patch
@spectrum-web-components/underlay Patch
@spectrum-web-components/base Patch
@spectrum-web-components/grid Patch
@spectrum-web-components/opacity-checkerboard Patch
@spectrum-web-components/reactive-controllers Patch
@spectrum-web-components/shared Patch
@spectrum-web-components/styles Patch
@spectrum-web-components/theme Patch
@spectrum-web-components/eslint-plugin Patch
@spectrum-web-components/stylelint-header-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

📚 Branch Preview Links

🔍 First Generation Visual Regression Test Results

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

Deployed to Azure Blob Storage: pr-6254

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

Copy link
Copy Markdown
Member

@cdransf cdransf left a comment

Choose a reason for hiding this comment

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

Looks awesome! ✨

@5t3ph 5t3ph added the run_vrt Triggers the Chromatic VRT run for 2nd-gen label May 8, 2026
Copy link
Copy Markdown
Contributor

@nikkimk nikkimk left a comment

Choose a reason for hiding this comment

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

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2nd gen These issues or PRs map to our 2nd generation work to modernizing infrastructure. Component:Button Includes ButtonBase, Clear Button, and Close Button run_vrt Triggers the Chromatic VRT run for 2nd-gen Status:Ready for review PR ready for review or re-review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants