react-email icon indicating copy to clipboard operation
react-email copied to clipboard

Add global styles to emails

Open liamb13 opened this issue 3 years ago • 1 comments

Adding global style as a feature could be nice.

I was able to make it work by creating a new file /emails/styles.tsx

// styles.tsx
export const main = {
  backgroundColor: '#000',
};
// email.tsx
import { main } from './styles'

Issue with this method

styles.tsx shows up in preview. Workaround is to name the file components.tsx which is filtered from the list

I wasn't able to get it to work if I had the file in a subfolder. Could be nice to have a /styles/ folder and ability to have multiple template styles there.

liamb13 avatar Jan 26 '23 05:01 liamb13

Yup! Let's add it.

bukinoshita avatar Jan 27 '23 16:01 bukinoshita