TailwindCSS with CSS Variables
Describe the Bug
I have a tailwind.config.ts file that uses CSS Variables:
{
theme: {
extend: {
colors: {
background: 'hsl(var(--color-background) / <alpha-value>)',
// ...
},
},
},
}
declared in a tailwind.css file:
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
:root {
--color-background: 0 0% 100%; /* white */
// ...
}
}
When using the <Tailwind config={tailwindConfig}> component, how does one load the tailwind.css file too so we can use custom Tailwind classnames?
The following does not work:
import { Container, Head, Html, Link, Tailwind, Text, Body } from '@react-email/components'
import tailwindConfig from '../../../../tailwind.config.ts'
import tailwindStylesheetUrl from '../../../styles/tailwind.css'
export function SomeEmail() {
return (
<Tailwind config={tailwindConfig}>
<Html lang="en" dir="ltr">
<Head>
<meta charSet="utf-8" />
<title>Welcome to André Casal!</title>
<style type="text/css">{tailwindStylesheetUrl}</style>
</Head>
<Body className="bg-background">
<Container>
<h1>
<Text>Welcome to André Casal!</Text>
</h1>
</Container>
</Body>
</Html>
</Tailwind>
)
}
Which package is affected (leave empty if unsure)
No response
Link to the code that reproduces this issue
NA
To Reproduce
NA
Expected Behavior
NA
What's your node version? (if relevant)
No response
assign this issue to me.
assign this issue to me.
Thanks @BHARATHI-GIT-HUB
Iam not able to host locally in my device is their any pre-requirement like docker.
@BHARATHI-GIT-HUB I am running into the same issue. Is there any update for how to use CSS variables with react-email and <Tailwind />? Thanks!
@andrecasal @LeathanTeal
I figured out a way to use variables directly in your <Tailwind/> component.
You can use the plugin @mertasan/tailwindcss-variables
NPM: @mertasan/tailwindcss-variables
I made a gist containing a demo, you can find it here
Let me know if you have any issues
Iam not able to host locally in my device is their any pre-requirement like docker.
Hi @BHARATHI-GIT-HUB, Have you resolved your setup issue?
There are no pre-requirements
You just need to cd into any of the projects and run the dev command.
e.g
cd web
npm run dev
@lordelogos Its working with mertasan plugin....
may i know what to do further??.....
may i know what to do further??.....
after selecting your project and setting it up locally you can now proceed to make your contribution You should also read the Contributing guidelines
