Skip to content

fix(button): centre icons via flex gap instead of margin#7402

Open
talissoncosta wants to merge 1 commit intomainfrom
fix/button-icon-spacing
Open

fix(button): centre icons via flex gap instead of margin#7402
talissoncosta wants to merge 1 commit intomainfrom
fix/button-icon-spacing

Conversation

@talissoncosta
Copy link
Copy Markdown
Contributor

@talissoncosta talissoncosta commented May 4, 2026

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Follow-up to a review comment on #7100 (thread) — icon-only buttons (theme='icon') sat with the icon visibly off-centre.

Cause: the <button> path applied mr-2 directly to iconLeft and ml-2 to iconRight. For icon-only buttons (32×32, display: flex; justify-content: center), the trailing margin pushed the icon ~4px to the left of true centre — justify-content: center re-centres the flex item, but the margin still shifts everything inside it.

Fix: wrap the button content in a flex span with gap-2, matching the existing <a> path that already uses this pattern. gap only inserts space between siblings (no leading/trailing space), so icon-only buttons centre cleanly while icon+label combinations keep their visual spacing unchanged.

How did you test this code?

  • Storybook → Components/Button → confirmed:
    • theme='icon' button: icon is centred in the 32×32 box (was offset left).
    • Icon + label buttons: spacing between icon and label unchanged.
    • Light + dark mode visually verified.
  • Chromatic snapshot diff (this PR) shows the centring correction on the existing button stories.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
flagsmith-frontend-preview Ready Ready Preview, Comment May 5, 2026 11:10am
flagsmith-frontend-staging Ready Ready Preview, Comment May 5, 2026 11:10am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview May 5, 2026 11:10am

Request Review

@github-actions github-actions Bot added the front-end Issue related to the React Front End Dashboard label May 4, 2026
@github-actions github-actions Bot added the fix label May 4, 2026
@talissoncosta talissoncosta marked this pull request as ready for review May 4, 2026 13:38
@talissoncosta talissoncosta requested a review from a team as a code owner May 4, 2026 13:38
@talissoncosta talissoncosta requested review from kyle-ssg and removed request for a team May 4, 2026 13:38
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

⚠️ Code review skipped — your organization's overage spend limit has been reached.

Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit at claude.ai/admin-settings/claude-code.

Once credits are available, reopen this pull request to trigger a review.

@talissoncosta talissoncosta removed the request for review from kyle-ssg May 4, 2026 13:38
@github-actions github-actions Bot added fix and removed fix labels May 4, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-api-test:pr-7402 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-e2e:pr-7402 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api:pr-7402 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-7402 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-7402 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-frontend:pr-7402 Finished ✅ Results

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  11 passed

Details

stats  11 tests across 8 suites
duration  10.1 seconds
commit  d14de72
info  🔄 Run: #16513 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  11 passed

Details

stats  11 tests across 8 suites
duration  49.8 seconds
commit  d14de72
info  🔄 Run: #16513 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  17 passed

Details

stats  17 tests across 14 suites
duration  1 minute, 3 seconds
commit  d14de72
info  🔄 Run: #16513 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  50.1 seconds
commit  d14de72
info  🔄 Run: #16513 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  11 passed

Details

stats  11 tests across 8 suites
duration  43.8 seconds
commit  22626b0
info  🔄 Run: #16523 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  11 passed

Details

stats  11 tests across 8 suites
duration  52.3 seconds
commit  22626b0
info  🔄 Run: #16523 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  48.9 seconds
commit  22626b0
info  🔄 Run: #16523 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  1 minute, 5 seconds
commit  22626b0
info  🔄 Run: #16523 (attempt 1)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

Visual Regression

16 screenshots compared. See report for details.
View full report

Zaimwa9
Zaimwa9 previously approved these changes May 4, 2026
Base automatically changed from feat/storybook-component-stories to main May 4, 2026 15:37
@talissoncosta talissoncosta dismissed Zaimwa9’s stale review May 4, 2026 15:37

The base branch was changed.

@talissoncosta talissoncosta requested a review from a team as a code owner May 4, 2026 15:37
@talissoncosta talissoncosta requested review from Zaimwa9 and khvn26 and removed request for a team May 4, 2026 15:37
@Zaimwa9
Copy link
Copy Markdown
Contributor

Zaimwa9 commented May 5, 2026

@talissoncosta can you rebase main please

The `<button>` path applied `mr-2` to iconLeft and `ml-2` to iconRight
directly on the icon element. For icon-only buttons (`theme='icon'`)
this margin pushed the icon off-centre against the 32×32 button
container — the icon sat ~4px to the left of true centre because
margin-right shifts the flex item before `justify-content: center`
re-centres it.

Wraps the button content in a flex span with `gap-2`, matching the
existing `<a>` path. Gap only inserts space between siblings (not
leading/trailing), so icon-only buttons now centre cleanly while
icon+label combinations keep the same visual spacing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added fix and removed fix labels May 5, 2026
@talissoncosta
Copy link
Copy Markdown
Contributor Author

@Zaimwa9 done, sorry for that.

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

Labels

fix front-end Issue related to the React Front End Dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants