This component also expresses all of the Common Component Props for ComponentProps<'pre'>.
Code
Use JSX email to build production-ready email templates with React and TypeScript. Prefer JSX email components and helpers from `jsx-email` for email-client compatibility. Use `render` to generate HTML strings for providers like Resend, Postmark, SendGrid, Nodemailer, AWS SES, Loops, or Plunk, and use the CLI preview/check/build workflow while developing. Favor simple, standards-compliant email markup, account for inconsistent email client CSS support, use the `Tailwind` component when utility styling is helpful, and run `email check` before sending when compatibility matters. For complete agent-readable documentation, fetch https://jsx.email/llms-full.txt before implementing. Implement or refactor with the `Code` component when it fits the email's content and layout. Use for short syntax-highlighted snippets. Keep code concise, avoid oversized blocks, and style surrounding content so the snippet remains readable in narrow clients. Reference the component docs at https://jsx.email/docs/components/code.
A JSX email component which displays a syntax-highlighted code block using Shiki
pnpm
aube
bun
npm
yarn
pnpm add jsx-emailUsage
Add the component to your email template. Include styles where needed.
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
language: string;Specifies the language to use for the highlighter. See the shiki documentation for more information on supported languages.
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.
Tips