Code
A JSX email component which displays a syntax-highlighted code block using <a href="https://shiki.matsu.io/">Shiki</a>
Install
Install the 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 component to your email template. Include styles where needed.
jsx
import { Code } from 'jsx-email';
const Email = () => {
return (
<Code>
{`
import { batman } from 'superheros';
import { joker } from 'villains';
const henchmen = joker.help();
batman.fight(henchmen);
batman.arrest(joker);
`}
</Code>
);
};import { Code } from 'jsx-email';
const Email = () => {
return (
<Code>
{`
import { batman } from 'superheros';
import { joker } from 'villains';
const henchmen = joker.help();
batman.fight(henchmen);
batman.arrest(joker);
`}
</Code>
);
};Component Props
ts
language: string;language: string;Specifies the language to use for the highlighter. See the shiki documentation for more information on supported languages.
ts
theme?: string;theme?: string;Optional. Defaults to 'nord'. Specifies the theme to use for the highlighter. See the shiki documentation for more information on supported themes, modifying themes, and how to make your own.
TIP
This component also expresses all of the Common Component Props for ComponentProps<'pre'>.