Skip to content

fix(tailwind): not all React Email components having styles inlined into their props#3592

Merged
gabrielmfern merged 4 commits into
resend:canaryfrom
yashs33244:fix/tailwind-section-padding-td
Jul 6, 2026
Merged

fix(tailwind): not all React Email components having styles inlined into their props#3592
gabrielmfern merged 4 commits into
resend:canaryfrom
yashs33244:fix/tailwind-section-padding-td

Conversation

@yashs33244

@yashs33244 yashs33244 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

What

Section splits its style so that padding goes to the inner <td> and everything else to the outer <table> - this is the Outlook/Klaviyo compatibility split. But when padding is set through a Tailwind class instead of style, it lands on the <table> and the <td> is bare:

<Tailwind><Section className="bg-white p-4">x</Section></Tailwind>
// -> <table style="background-color:…;padding:1rem"><tbody><tr><td>x</td>…

Section is missing from componentsToTreatAsElements, so isComponent(Section) is true. The Tailwind walker therefore renders Section with its className still attached, which Section spreads onto the <table>, and then inlines every utility onto that plain <table> - bypassing the <td> split. Container (which has the same split) is already in the list.

Fix

Add Section to componentsToTreatAsElements so its Tailwind styles are inlined onto its style prop, letting the existing split route padding to the <td>:

// -> <table style="background-color:…"><tbody><tr><td style="padding:1rem">x</td>…

Two lines (import + array entry), matching Container. Added a regression test; all tailwind/section/container/row/column tests pass.


Summary by cubic

Fix Tailwind utilities on Section, Row, and Column so classes inline onto the correct tag. Section now routes padding to the inner <td> for Outlook/Klaviyo; Row/Column inline onto their own tags, matching style behavior and Container.

  • Bug Fixes
    • Treat Section, Row, and Column as elements in the Tailwind walker so utilities inline into style, enabling Section’s padding-to-<td> split.
    • Add tests for <Section className="p-4">, <Row className="p-4">, and <Column className="p-4">.

Written for commit bf06fe0. Summary will update on new commits.

Review in cubic

Section was not in componentsToTreatAsElements, so the Tailwind walker
left its className on the rendered <table> and inlined every utility
onto that table, bypassing Section's own padding-to-<td> split. Treat
Section like Container so padding utilities reach the <td> (Outlook/
Klaviyo compatibility), the same as style-prop padding already does.
Copilot AI review requested due to automatic review settings June 23, 2026 07:53
@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

@yashs33244 is attempting to deploy a commit to the resend Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@changeset-bot

changeset-bot Bot commented Jun 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: bf06fe0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
react-email Patch
@react-email/editor Patch
@react-email/ui Patch

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

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 3 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Small fix adding Section to the Tailwind element list so padding utilities route to the inner , matching Container's behavior. Includes a regression test and changeset. No business logic, infrastructure, or security impact.

Re-trigger cubic

@github-actions github-actions Bot added the linear-synced PR has been synced to Linear label Jun 23, 2026

@gabrielmfern gabrielmfern left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a great catch! Thank you!

We should make sure that all components are there too. Can you do that?

Extends the Section fix to the other layout primitives so a class like
<Column className="p-4"> / <Row className="p-4"> inlines onto the
component's own tag. Html/Head are left out (they must be walked for the
<head> style injection) and Markdown is left out (its explicit style prop
would override the injected one).
@yashs33244

Copy link
Copy Markdown
Contributor Author

Done, went through all the components. Added Column and Row next to Section, since those are the other primitives that render to a single styleable tag (<td> and the outer <table>), so a class like p-4 on them now inlines onto their own element. Test for each added.

A few I left out on purpose:

  • Html / Head: the Tailwind pass has to walk into them to find <head> and inject the non-inlinable styles, so treating them as leaf elements breaks that (5 tailwind tests fail if I add them).
  • Markdown: it sets style={markdownContainerStyles} explicitly, which overrides any injected style, so adding it actually drops the user's classes.
  • Font: only renders a <style> tag, nothing to inline.

One honest note: Column and Row already rendered correctly via the host-element fallback, so this is mostly for consistency and so they go through React instead of the tree-walker's direct-invoke path. Section was the one that genuinely needed the list, because it reads props.style to do its padding-to-<td> split.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

0 issues found across 3 files (changes from recent commits).

Re-trigger cubic

@gabrielmfern gabrielmfern changed the title fix(tailwind): route Section padding to the inner td fix(tailwind): not all React Email components being tread as elements Jul 6, 2026
@gabrielmfern gabrielmfern changed the title fix(tailwind): not all React Email components being tread as elements fix(tailwind): not all React Email components having styles inlined into their props Jul 6, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 6, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/react-email@3592

commit: bf06fe0

Signed-off-by: gabriel miranda <gabriel@resend.com>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

0 issues found across 2 files (changes from recent commits).

Re-trigger cubic

@gabrielmfern gabrielmfern merged commit fc8318c into resend:canary Jul 6, 2026
13 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

linear-synced PR has been synced to Linear

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants