Fix Avatar sizing in Button leadingVisual slot#7975
Conversation
🦋 Changeset detectedLatest commit: a06a00a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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>
|
There was a problem hiding this comment.
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-widthalongsidewidthin the base.Avatarrule. - Add
min-widthfor each responsive breakpoint (narrow/regular/wide) underdata-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
| :where(.Avatar) { | ||
| display: inline-block; | ||
| width: var(--avatarSize-regular); | ||
| min-width: var(--avatarSize-regular); | ||
| height: var(--avatarSize-regular); |
Co-authored-by: jonrohan <54012+jonrohan@users.noreply.github.com>
Co-authored-by: jonrohan <54012+jonrohan@users.noreply.github.com>
|
👋 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. |
Fixes #7974
Avatars passed into Button's
leadingVisualslot render at the wrong width. Globalimg { max-width: 100% }collides with the less-specific Avatarwidth(set via CSS var), and because Button usesmin-contentfor the leadingVisual grid area,max-widthcan resolve to0, shrinking the image.Changelog
New
Changed
Avatar.module.css: setmin-widthalongsidewidth(base rule + all responsive breakpoints) so Avatars never shrink below their intended size.AvatarStack.module.css: setmin-width: var(--avatar-stack-size)on.AvatarItem. The Avatarmin-widthresolves 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
Testing & Reviewing
Verify via the Button-with-Avatar
leadingVisualcase (Avatar retains its expected width) and the AvatarStackCustomSizeOnChildrenstory (children remain uniformly sized at the smallest child's size).Merge checklist