Skip to content

Fix Avatar sizing in Button leadingVisual slot#7975

Open
Copilot wants to merge 5 commits into
mainfrom
copilot/fix-avatar-sizing-in-button
Open

Fix Avatar sizing in Button leadingVisual slot#7975
Copilot wants to merge 5 commits into
mainfrom
copilot/fix-avatar-sizing-in-button

Conversation

Copilot AI commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Fixes #7974

Avatars passed into Button's leadingVisual slot render at the wrong width. Global img { max-width: 100% } collides with the less-specific Avatar width (set via CSS var), and because Button uses min-content for the leadingVisual grid area, max-width can resolve to 0, shrinking the image.

Changelog

New

Changed

  • Avatar.module.css: set min-width alongside width (base rule + all responsive breakpoints) so Avatars never shrink below their intended size.
  • AvatarStack.module.css: set min-width: var(--avatar-stack-size) on .AvatarItem. The Avatar min-width resolves to each child's inline --avatarSize-regular, so without this override custom-size children rendered at their individual sizes instead of the uniform stack size.

Removed

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Verify via the Button-with-Avatar leadingVisual case (Avatar retains its expected width) and the AvatarStack CustomSizeOnChildren story (children remain uniformly sized at the smallest child's size).

Merge checklist

@changeset-bot

changeset-bot Bot commented Jun 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a06a00a

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

This PR includes changesets to release 1 package
Name Type
@primer/react 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

…isual

Co-authored-by: jonrohan <54012+jonrohan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix avatar image sizing in Button component Fix Avatar sizing in Button leadingVisual slot Jun 11, 2026
Copilot AI requested a review from jonrohan June 11, 2026 17:49
@jonrohan jonrohan marked this pull request as ready for review June 11, 2026 17:49
@jonrohan jonrohan requested a review from a team as a code owner June 11, 2026 17:49
Copilot AI review requested due to automatic review settings June 11, 2026 17:49
@github-actions github-actions Bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Jun 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

To publish a canary release for integration testing, apply the Canary Release label to this PR.

Copilot AI 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.

Pull request overview

This PR addresses a layout bug where Avatar images can collapse to an incorrect width when rendered inside Button’s leadingVisual slot (due to min-content sizing interacting with a global img { max-width: 100% } rule). The fix makes Avatars maintain their intended rendered width by enforcing a matching min-width.

Changes:

  • Add min-width alongside width in the base .Avatar rule.
  • Add min-width for each responsive breakpoint (narrow/regular/wide) under data-responsive.
  • Add a patch changeset documenting the user-visible fix.
Show a summary per file
File Description
packages/react/src/Avatar/Avatar.module.css Adds min-width to prevent Avatar images collapsing under constrained grid sizing contexts.
.changeset/avatar-min-width.md Patch changeset describing the Avatar sizing fix (notably for Button leadingVisual).

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 1

Comment on lines 1 to 5
:where(.Avatar) {
display: inline-block;
width: var(--avatarSize-regular);
min-width: var(--avatarSize-regular);
height: var(--avatarSize-regular);
Copilot AI and others added 2 commits June 11, 2026 20:36
Co-authored-by: jonrohan <54012+jonrohan@users.noreply.github.com>
Co-authored-by: jonrohan <54012+jonrohan@users.noreply.github.com>
@primer-integration

primer-integration Bot commented Jun 15, 2026

Copy link
Copy Markdown

👋 Hi from github/github-ui! Your npm packages integration PR is ready: https://github.com/github/github-ui/pull/23392.

Will report CI results once ready.

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

Labels

integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avatar in Button leadingVisual slot does not properly size img due to conflicting styles

4 participants