fix(button): move icon vertical-align from inline style to a class default - #1834
Conversation
…fault The icon `<img>` hardcoded `style="vertical-align: baseline; max-width: 100%"` alongside `:class="iconClass"`. Because Tailwind utilities are imported `!important` in email, a passed `iconClass` like `align-text-top` correctly overrides the inline `baseline` in a normal (inlined) build, so the hardcoded inline style is effectively dead. But in a class-first workflow that de-inlines residual `style=""` back into classes, that dead inline `vertical-align: baseline` resurfaces as a conflicting `align-baseline` utility stacked next to the authored `align-text-top`, and the two fight. Move the defaults to a `twMerge`'d class (`max-w-full align-baseline`) so `iconClass` cleanly overrides them and no inline `vertical-align` is emitted. Rendered output is unchanged for the default and inlined builds.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Button component replaces inline icon sizing and alignment styles with merged Tailwind classes for left- and right-positioned icons. Custom ChangesButton icon styling
Estimated code review effort: 1 (Trivial) | ~2 minutes Mergeability Score: ⚪ Minimal · up to This localized change moves button icon defaults into mergeable utility classes, preserving existing default rendering while making alignment overrides reliable; no actionable merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
The icon
<img>in<Button>hardcodes an inline style alongside:class:Since Tailwind utilities are imported
!importantin email (@import "tailwindcss/utilities" important), a passediconClasslikealign-text-topalready wins over the inlinevertical-align: baselinein a normal inlined build. So the hardcoded inline style is effectively dead — the real cascade resolves to the class.The trouble shows up in a class-first workflow that de-inlines residual
style=""back into utility classes: that dead inlinevertical-align: baselinegets converted into analign-baselineutility and stacked next to the authoredalign-text-top. Two conflicting!importantvertical-align utilities land on one element, and the wrong one can win.Fix
Move the icon defaults from an inline style to a
twMerge'd class, soiconClassoverrides them cleanly and no inlinevertical-alignis emitted:twMergealready collapses vertical-align conflicts, so:iconClass='') →max-w-full align-baseline(unchanged behavior)iconClass="align-text-top"→max-w-full align-text-topOutput is identical for the default and for inlined builds; the class-first path now yields a single, correct vertical-align. Applied to both icon positions (left/right).
Summary by CodeRabbit