Background
A JSX email component for background images in your Email template
Install
Install the component from your command line
console
pnpm add jsx-emailpnpm add jsx-emailconsole
bun add jsx-emailbun add jsx-emailconsole
npm add jsx-emailnpm add jsx-emailconsole
yarn add jsx-emailyarn add jsx-emailUsage
Add the background component to your email template.
jsx
import { Body, Column, Html, Section } from 'jsx-email';
const Email = () => {
return (
<Html lang="en">
<Body>
<Background src="link-to-image" bgColor="#FFFFFF" width={600}>
<Row>
<Column>Content goes here</Column>
</Row>
</Background>
</Body>
</Html>
);
};import { Body, Column, Html, Section } from 'jsx-email';
const Email = () => {
return (
<Html lang="en">
<Body>
<Background src="link-to-image" bgColor="#FFFFFF" width={600}>
<Row>
<Column>Content goes here</Column>
</Row>
</Background>
</Body>
</Html>
);
};Component Props
tsx
interface BackgroundProps
extends Omit<React.ComponentPropsWithoutRef<'td'>, 'height' | 'width' | 'bgcolor'> {
src: string;
bgColor?: string;
bgRepeat?: 'repeat' | 'no-repeat';
height?: number;
width?: number;
}interface BackgroundProps
extends Omit<React.ComponentPropsWithoutRef<'td'>, 'height' | 'width' | 'bgcolor'> {
src: string;
bgColor?: string;
bgRepeat?: 'repeat' | 'no-repeat';
height?: number;
width?: number;
}tsx
src: string;src: string;The path to the image
tsx
bgColor?: string;bgColor?: string;The hex code that represents the fallback background-color incase the image doesn't load
tsx
bgRepeat?: 'repeat' | 'no-repeat';bgRepeat?: 'repeat' | 'no-repeat';A string that represents the value of background-repeat. Default value is no-repeat
tsx
height?: number;height?: number;The height of the container in pixels
tsx
width?: number;width?: number;The width of the container in pixels