Fix button icon centering on Firefox for xs size

shoelace-style/webawesome

Firefox rendered the slotted <wa-icon> inside a <wa-button size="xs"> off‑centre, breaking visual symmetry for small icon‑only buttons.

背景

Firefox’s rendering of xs‑size icon buttons was misaligned because the label flex container only centered its children vertically.

The original styles defined .is-icon-button .label { display: flex; } and .label::slotted(wa-icon) { align-self: center; }, which aligns the icon along the cross‑axis (vertical) but leaves the inline axis (horizontal) uncontrolled, causing a few‑pixel shift in Firefox.

Consequently, developers resorted to the workaround <wa-icon auto-width> to force the host to match the SVG’s intrinsic width, a pattern that broke the unified API surface.

技術的な変更

The fix adds justify-content: center to the label flex container, ensuring horizontal centering of the slotted icon host.

@@ -278,6 +278,11 @@ export default css`

   .is-icon-button .label {
     display: flex;
+    /* Center the slotted icon horizontally so the icon sits in the
+       middle of the square label regardless of the icon host's
+       intrinsic width. Without this, Firefox renders the icon off-
+       centre at small sizes (e.g. size="xs"). */
+    justify-content: center;
   }

   .label::slotted(wa-icon) {

The added comment explains the rationale and references the Firefox‑specific symptom.

With justify-content: center, the label now aligns the icon host along both axes, matching Chromium‑based browsers’ behaviour while keeping the existing align-self: center for vertical alignment.

No other files change, and the component’s API remains untouched; the auto-width attribute is no longer required for correct rendering.

設計判断

The change prefers adjusting existing layout rules over introducing new attributes.

By extending the .is‑icon‑button .label rule, the fix leverages the component’s existing flex‑based layout, minimizing CSS surface area and preserving backward compatibility.

Alternative approaches, such as adding a new auto-width‑style flag or creating a browser‑specific stylesheet, were rejected to keep the component’s API stable and avoid branching logic.

Thus, the chosen solution adheres to the library’s design principle of incremental CSS adjustments that do not alter public component contracts.

まとめ

Adding justify-content: center resolves the Firefox‑only misalignment of xs‑size icon buttons without affecting other browsers or requiring developer workarounds, illustrating a minimal‑impact layout fix that respects existing component semantics.

記事メタデータ

Generated by:
gpt-oss-120b for DiffDaily
LLM Trace:
a643cdd8

この記事はAIによって自動生成されています。内容の正確性については、必ずソースコードやPRを確認してください。

品質レビュー結果

Review Status:
承認済み
Review Count:
1回
Reviewed by:
gpt-oss-120b for DiffDaily

Review Criteria:

記事構成 ✓ PASS

Title, Context, Technical Detailの存在と明確さ

リード文・背景・技術的変更・設計判断・まとめの5セクションが揃っており、総論→各論→結論の流れが明確です。

カスタムMarkdown構文 ✓ PASS

シンタックスハイライト・GitHubリンク記法の正確性

コードブロックは正しいdiffシンタックスで記載され、PRリンクは [PR #2467](URL) 形式で正しくリンク化されています。ファイル名付きハイライトは不要なので問題ありません。

対象読者への適合性 ✓ PASS

エンジニア向けの適切な技術レベルと表現

エンジニア向けの専門的用語で記述されており、初心者向けの余計な説明はありません。

パラグラフ・ライティング ✓ PASS

トピックセンテンス・1段落1トピック・段落長

各セクションが総論・各論・結論のパラグラフに分かれ、1文目がトピックセンテンスとなっています。段落は1テーマに絞られ、長さも適切で空行で区切られています。

Diff内容との照合 ✓ PASS

コードブロックとDiff内容の一致

記事中の diff は提供された PR の diff と内容・コメント・行番号が完全に一致しており、抜粋以外の不整合はありません。

技術用語の正確性 ✓ PASS

技術用語の正確な使用

「slotted」「justify-content」「flex」「auto‑width」などの用語は PR と一致し、誤用は見られません。

説明の技術的正確性 ✓ PASS

技術的主張の正確性と論理性

水平センタリングの原因と解決策が PR の説明と合致しており、技術的に正確です。

事実の突合 ✓ PASS

PR情報による主張の裏付け(ハルシネーション検出)

記事のすべての主張が PR タイトル・説明・diff に裏付けられており、推測や捏造はありません。

数値・固有名詞の確認 ✓ PASS

PR番号・コミットID・バージョン等の正確性

PR 番号 #2467 のみが言及され、正確に記載されています。その他数値や特定の数値的主張はありません。

タイトル・説明との一致 ✓ PASS

記事タイトル・説明とPR内容の一致

記事タイトルは PR タイトルの内容を適切に要約しており、意味的に一致しています。

外部知識の正確性 ✓ PASS

PRに記載のない外部知識(LTS、サポート状況など)の不使用

バージョンサポートやリリース日程など PR に無い外部情報は含まれていません。

時間表現の正確性 ✓ PASS

時間表現がPR情報と一致しているか

時間的表現の歪曲はなく、PR の記述と整合しています。