Conditional
Use HTML conditional comments effortlessly
Install
Install the component from your command line
pnpm add jsx-emailbun add jsx-emailnpm add jsx-emailyarn add jsx-emailUsage
import { Conditional, Head } from 'jsx-email';
const Email = () => { return ( <Head> {/* MSO-specific content */} <Conditional mso={true}> <meta content="mso-content" /> </Conditional>
{/* Custom conditional */} <Conditional expression="lt ie 10"> <meta content="legacy-ie" /> </Conditional> </Head> );};Props
TypeScript Interface
interface ConditionalProps { children?: React.ReactNode; expression?: string; mso?: boolean;}Optional Props
expression
expression?: string;Custom conditional expression for HTML comment. Example: 'lt ie 10' produces <!--[if lt ie 10]>.
head
head?: boolean;Places the conditional in the email template’s head section.
mso
mso?: boolean;- When
true: Outputs<!--[if mso]> - When
false: Outputs<!--[if !mso]><!--> ... <!--<![endif]-->
Children Props
children?: React.ReactNode;Content to be wrapped in the conditional comment.