Skip to content

fix(ui-buttons): fix textAlign center on Buttons without icon#2539

Open
balzss wants to merge 1 commit intomasterfrom
fix/button-text-align
Open

fix(ui-buttons): fix textAlign center on Buttons without icon#2539
balzss wants to merge 1 commit intomasterfrom
fix/button-text-align

Conversation

@balzss
Copy link
Copy Markdown
Contributor

@balzss balzss commented May 5, 2026

Summary

  • In v11.7 the v2 BaseButton's content wrapper was changed from display: block to display: flex. As a flex container with a single shrunk-to-content child span, textAlign: center no longer had anything to center — buttons without an icon stayed left-aligned. Buttons with an icon kept working because their extra childrenLayout wrapper has width: 100% and an explicit justifyContent: center.
  • Fix: add justifyContent: textAlign === 'center' ? 'center' : 'flex-start' to the content flex container in packages/ui-buttons/src/BaseButton/v2/styles.ts, mirroring the logic already used in childrenLayout.

Test Plan

  • Render a Button with textAlign="center" and display="block" (no renderIcon) — label should be horizontally centered.
  • Render the same Button with a renderIcon — label + icon should still be horizontally centered (no regression).
  • Render a Button with textAlign="start" (default) — label should remain left-aligned, both with and without an icon.
  • pnpm run test:vitest ui-buttons passes.
  • Visual regression suite for Button passes.

Jira Reference

Fixes INSTUI-5015

🤖 Generated with Claude Code

The content wrapper changed from display:block to display:flex in the v2
button rewrite, which made textAlign:center ineffective on the shrunk
children span. Add justifyContent based on textAlign so text is centered
regardless of whether an icon is present.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://instructure.design/pr-preview/pr-2539/

Built to branch gh-pages at 2026-05-05 15:11 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant