import * as React from 'react'; import { marginProperties, paddingProperties } from './margin-properties.js'; export type BodyProps = Readonly>; export const Body = React.forwardRef( ({ children, style, ...props }, ref) => { const bodyStyle: Record = { background: style?.background, backgroundColor: style?.backgroundColor, }; if (style) { for (const property of [...marginProperties, ...paddingProperties]) { // We reset the margin if the user sets it, this mimics the // same behavior that would happen if this was only using the body. // This avoids the incoming margin summing up with the margin // defined by the email client on the body, or by the browser itself bodyStyle[property] = style[property] !== undefined ? 0 : undefined; } } return ( {/* Yahoo and AOL remove all styles of the body element while converting it to a div, so we need to apply them to to an inner cell. See https://github.com/resend/react-email/issues/662. */}
{children}
); }, ); Body.displayName = 'Body';