Skip to content

fix(text): keep CSS functions intact in the margin shorthand - #3940

Open
durgasnv wants to merge 1 commit into
resend:canaryfrom
durgasnv:fix/text-margin-css-functions
Open

durgasnv wants to merge 1 commit into
resend:canaryfrom
durgasnv:fix/text-margin-css-functions

Conversation

@durgasnv

@durgasnv durgasnv commented Nov 28, 2026 •

Copy link
Copy Markdown

Related issue or discussion

Fixes #3939

What this changes

<Text> breaks the margin shorthand into its four sides, but it split the value on every space. That meant anything with a CSS function in it fell apart. For example, margin: 'calc(10px + 2px) 0' came out as margin-top:calc(10px;margin-right:+;margin-bottom:2px), which email clients just ignore.

Now the value is only split on spaces that sit outside parentheses, so calc(), max(), clamp() and nested var() stay in one piece. Plain values like 10px 20px work the same as before.

I added tests for computeMargins and for the rendered <Text> output. Both fail without the fix and pass with it.


Summary by cubic

Fixes the <Text> component's margin shorthand parsing so CSS functions like calc(), max(), and clamp() stay intact instead of being split into broken pieces.

Previously, margin: 'calc(10px + 2px) 0' was split on every space, producing invalid CSS that email clients ignored. The value is now only split on spaces outside parentheses, so CSS functions and nested var() calls survive while plain values like 10px 20px work as before. Added tests for both the margin computation utility and the rendered <Text> output.

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

View guided diff

The margin shorthand was split on every space, so values like
calc(10px + 2px) 0 turned into broken pieces. Now it only splits
on spaces outside parentheses.

Fixes resend#3939
@vercel

vercel Bot commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

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

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Nov 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c97101c

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

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

This branch has not been deployed

No deployments
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.

Text: margin shorthand with calc(), max() or other CSS functions is split into invalid values

1 participant